This commit is contained in:
2020-02-03 19:07:48 +00:00
parent 6c36a2f470
commit 694e2e1284
2 changed files with 51 additions and 45 deletions

View File

@@ -1570,7 +1570,7 @@ same as the server does but in a central location here for all tests to use.
//This test is time zone sensitive and thus uses relative today
//If any other test are to fail this way they will need to be done the same way
var WidgetNameStart = "DateTokenNextMonthFilterWorks";
long IncludedWidgetId = 0;
long ExcludedWidgetId = 0;
@@ -3334,8 +3334,13 @@ same as the server does but in a central location here for all tests to use.
w.name = Util.Uniquify(WidgetNameStart);
w.notes = "blah";
w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
w.startDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).ToUniversalTime();
w.endDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).AddHours(1).ToUniversalTime();
//ToOffsetAdjustedUniversalTime
// w.startDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).ToUniversalTime();
// w.endDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).AddHours(1).ToUniversalTime();
w.startDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).ToOffsetAdjustedUniversalTime();
w.endDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).AddHours(1).ToOffsetAdjustedUniversalTime();
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
Util.ValidateDataReturnResponseOk(a);
@@ -3344,8 +3349,10 @@ same as the server does but in a central location here for all tests to use.
//Excluded widget
w.name = Util.Uniquify(WidgetNameStart);
//First day of this month minus 2 days equals second to last day of last month
w.startDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).AddDays(-2).ToUniversalTime();
w.endDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).AddDays(-2).AddHours(1).ToUniversalTime();
// w.startDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).AddDays(-2).ToUniversalTime();
// w.endDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).AddDays(-2).AddHours(1).ToUniversalTime();
w.startDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).AddDays(-2).ToOffsetAdjustedUniversalTime();
w.endDate = new DateTime(DateTime.Today.Year, MonthNumberUnderTest, 1, 00, 00, 00).AddDays(-2).AddHours(1).ToOffsetAdjustedUniversalTime();
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
@@ -3383,27 +3390,8 @@ same as the server does but in a central location here for all tests to use.
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
//NOW FETCH WIDGET LIST WITH FILTER
//-8 example
//" where (awidget.name Like 'DateTokenAprilFilterWorks%') AND (awidget.startdate >'2020-04-01T07:59:59.0000000' AND awidget.startdate <'2020-05-01T08:00:00.0000000')"
//"{\"data\":{\"id\":703,\"concurrencyToken\":7090259,\"name\":\"DateTokenAprilFilterWorks 1580754102534\",\"serial\":703,\"dollarAmount\":null,\"active\":null,\"roles\":0,
//\"startDate\":\"2020-04-01T07:00:00Z\",\"endDate\":\"2020-04-01T08:00:00Z\",\"notes\":\"blah\",\"count\":null,\"customFields\":\"{\\\"c1\\\":\\\"2019-02-08T06:31:48.0019809Z\\\",\\\"c2\\\":\\\"c2 text\\\",\\\"c3\\\":\\\"333\\\",\\\"c4\\\":\\\"true\\\",\\\"c5\\\":\\\"5.55\\\"}\",\"tags\":[],\"userId\":null}}"
//(awidget.startdate >'2020-04-01T07:59:59.0000000'
//Ok, here's the issue:
//This test is run when my local time is winter time or "standard time" which is -8utc
//this test creates a future record for April which will be in DST or "daylight saving time" which is -7utc because it uses a library method to convert to universal time
//which takes into account the date.
//In other words, test code is using conversions based on DST PST effective of the created date falls on
//At the server it's just blindly doing -8 because the user settings are at -8
//This means the server is filtering an april date using the forced -8 but the client is using the actual -7 so they are an hour out
//Fixes:
//Is it an issue? User is normally going to select specific dates and times regardless of time zone so this client code is actually a bit off when you think of it that way
//So test client should take into account user options setting rather than local date setting?
//Or, should server instead of having hard coded offset just have user's time zone and it in turn does the calcs properly
//so local users doesn't select an offset but rather a time zone and let .net handle all the conversions
//In future there won't be a daylight saving time in pacific time zone likely
a = await Util.GetAsync($"DataList/list?DataListKey=TestWidgetDataList&Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
Util.ValidateDataReturnResponseOk(a);
Util.ValidateHTTPStatusCode(a, 200);
@@ -4395,7 +4383,7 @@ same as the server does but in a central location here for all tests to use.
List<long> IDInResultList = new List<long>();
int InclusiveMatchCount = 0;
int ExclusiveMatchCount = 0;
foreach (JArray ja in v)
foreach (JArray ja in v)
{
JObject o = ja[0] as JObject;
if (InclusiveWidgetIdList.Contains(o["v"].Value<long>()))
@@ -5025,7 +5013,7 @@ same as the server does but in a central location here for all tests to use.
List<long> IDInResultList = new List<long>();
int InclusiveMatchCount = 0;
int ExclusiveMatchCount = 0;
foreach (JArray ja in v)
foreach (JArray ja in v)
{
JObject o = ja[0] as JObject;
if (InclusiveWidgetIdList.Contains(o["v"].Value<long>()))
@@ -5642,7 +5630,7 @@ same as the server does but in a central location here for all tests to use.
List<long> IDInResultList = new List<long>();
int InclusiveMatchCount = 0;
int ExclusiveMatchCount = 0;
foreach (JArray ja in v)
foreach (JArray ja in v)
{
JObject o = ja[0] as JObject;
if (InclusiveWidgetIdList.Contains(o["v"].Value<long>()))
@@ -5765,7 +5753,7 @@ same as the server does but in a central location here for all tests to use.
List<long> IDInResultList = new List<long>();
int InclusiveMatchCount = 0;
int ExclusiveMatchCount = 0;
foreach (JArray ja in v)
foreach (JArray ja in v)
{
JObject o = ja[0] as JObject;
if (InclusiveWidgetIdList.Contains(o["v"].Value<long>()))
@@ -5889,7 +5877,7 @@ same as the server does but in a central location here for all tests to use.
List<long> IDInResultList = new List<long>();
int InclusiveMatchCount = 0;
int ExclusiveMatchCount = 0;
foreach (JArray ja in v)
foreach (JArray ja in v)
{
JObject o = ja[0] as JObject;
if (InclusiveWidgetIdList.Contains(o["v"].Value<long>()))

50
util.cs
View File

@@ -8,17 +8,28 @@ using System.Collections.Concurrent;
namespace raven_integration
{
public static class TimeZoneAdjustmentExtension
{
public static DateTime ToOffsetAdjustedUniversalTime(this DateTime dtIn)
{
//Date filtering tests MUST use a relative time zone adjusted to users's forced user options time zone
//or the tests that cross dst / pst boundaries will fail
//See servers spec doc core-locale-currency-numbers-time-and-dates.txt for details
double TIME_ZONE_ADJUSTMENT = -8;
Double TimeZoneAdjustment = (TIME_ZONE_ADJUSTMENT) * -1;
return dtIn.AddHours(TimeZoneAdjustment).ToUniversalTime();
}
}
public static class Util
{
//#######################################################################################################
public static string API_BASE_URL = "http://localhost:7575/api/v8/";
// public static string API_BASE_URL = "https://test.helloayanova.com/api/v8.0/";
// public static string API_BASE_URL = "https://test.helloayanova.com/api/v8.0/";
public static string TEST_DATA_FOLDER = @"..\..\..\testdata\";
//Date filtering tests MUST use a relative time zone adjusted to users's forced user options time zone
//or the tests that cross dst / pst boundaries will fail
//See servers spec doc core-locale-currency-numbers-time-and-dates.txt for details
public const decimal TIME_ZONE_ADJUSTMENT = -8;
//#######################################################################################################
@@ -44,19 +55,26 @@ namespace raven_integration
private static AutoId Auto { get; } = new AutoId(0);
//DateTime stuff
//DateTime adjustment methods for relative date filter testing
// public static DateTime RelativeToday()
// {
// Double TimeZoneAdjustment = ((double)TIME_ZONE_ADJUSTMENT) * -1;
// return DateTime.Today.AddHours(TimeZoneAdjustment);
// }
// public static DateTime RelativeNow()
// {
// Double TimeZoneAdjustment = ((double)TIME_ZONE_ADJUSTMENT) * -1;
// return DateTime.Now.AddHours(TimeZoneAdjustment);
// }
// public static DateTime ToOffsetAdjustedUniversalTime(DateTime dtIn)
// {
// Double TimeZoneAdjustment = ((double)TIME_ZONE_ADJUSTMENT) * -1;
// return dtIn.AddHours(TimeZoneAdjustment).ToUniversalTime();
// }
public static DateTime RelativeToday()
{
Double TimeZoneAdjustment = ((double)TIME_ZONE_ADJUSTMENT) * -1;
return DateTime.Today.AddHours(TimeZoneAdjustment);
}
public static DateTime RelativeNow()
{
Double TimeZoneAdjustment = ((double)TIME_ZONE_ADJUSTMENT) * -1;
return DateTime.Now.AddHours(TimeZoneAdjustment);
}
public static string Uniquify(string s)
{