public void Test_AccumulatedAttributes_GetValueAtDateTime() { using (var attrs = new AccumulatedAttributes <int>(1)) { attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc), 1); attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 10), DateTimeKind.Utc), 2); Assert.True( attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 0), DateTimeKind.Utc), out int value) && value == 1, "Failed to locate first attribute with preceding time"); Assert.True( attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc), out value) && value == 1, "Failed to locate first attribute with exact time"); Assert.True( attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 5), DateTimeKind.Utc), out value) && value == 1, "Failed to locate first attribute with trailing time"); Assert.True( attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 10), DateTimeKind.Utc), out value) && value == 2, "Failed to locate second attribute with exact time"); Assert.True( attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 20), DateTimeKind.Utc), out value) && value == 2, "Failed to locate second attribute with trailing time"); } }
public void Test_AccumulatedAttributes_GetLatest() { using (var attrs = new AccumulatedAttributes <int>(1)) { attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc), 1); attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 2), DateTimeKind.Utc), 2); Assert.Equal(2, attrs.GetLatest()); } }
public void Test_AccumulatedAttributes_DiscardAllButLatest() { using (var attrs = new AccumulatedAttributes <int>(1)) { // Add a couple of attributes, check discard preserves the last one attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc), 1); attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 10), DateTimeKind.Utc), 2); attrs.DiscardAllButLatest(); Assert.Equal(1, attrs.NumAttrs); Assert.Equal(2, attrs.GetLatest()); } }
public void Test_AccumulatedAttributes_GetAgeOfCorrectionValueAtDateTime() { using (var attrs = new AccumulatedAttributes <byte>(1)) { attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc), 10); attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 10), DateTimeKind.Utc), 20); Assert.Equal(10, attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 5), DateTimeKind.Utc), 0)); Assert.Equal(20, attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 15), DateTimeKind.Utc), 0)); } }
public void Test_AccumulatedAttributes_GetCCAValueAtDateTime() { using (var attrs = new AccumulatedAttributes <byte>(1)) { attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc), 10); attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 10), DateTimeKind.Utc), 20); Assert.Equal(10, attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 5), DateTimeKind.Utc), CellPassConsts.NullCCA)); Assert.Equal(20, attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 15), DateTimeKind.Utc), CellPassConsts.NullCCA)); } }
public void Test_AccumulatedAttributes_GetMachineSpeedValueAtDateTime() { using (var attrs = new AccumulatedAttributes <double>(1)) { attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc), 1.0); attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 10), DateTimeKind.Utc), 2.0); Assert.Equal(1.0, attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 5), DateTimeKind.Utc), Consts.NullDouble)); Assert.Equal(2.0, attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 15), DateTimeKind.Utc), Consts.NullDouble)); } }
public void Test_AccumulatedAttributes_GetGPSModeAtDateTime() { using (var attrs = new AccumulatedAttributes <GPSMode>(1)) { attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc), GPSMode.Fixed); attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 10), DateTimeKind.Utc), GPSMode.Float); Assert.Equal(GPSMode.Fixed, attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 5), DateTimeKind.Utc), CellPassConsts.NullGPSMode)); Assert.Equal(GPSMode.Float, attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 15), DateTimeKind.Utc), CellPassConsts.NullGPSMode)); } }
public void Test_AccumulatedAttributes_GetOnGroundAtDateTime() { using (var attrs = new AccumulatedAttributes <OnGroundState>(1)) { attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc), OnGroundState.No); attrs.Add(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 10), DateTimeKind.Utc), OnGroundState.YesLegacy); Assert.Equal(OnGroundState.No, attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 5), DateTimeKind.Utc), OnGroundState.No)); Assert.Equal(OnGroundState.YesLegacy, attrs.GetValueAtDateTime(DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 15), DateTimeKind.Utc), OnGroundState.No)); } }