public void EqualsTest() { var timeRange1 = new TimeRange(_start, _end); var timeRange2 = new TimeRange(_start, _end); var timeRange3 = new TimeRange(_start.AddMilliseconds(-1), _end.AddMilliseconds(1)); timeRange1.Equals(timeRange2).Should().Be.True(); timeRange1.Equals(timeRange3).Should().Be.False(); timeRange2.Equals(timeRange1).Should().Be.True(); timeRange2.Equals(timeRange3).Should().Be.False(); }
public void EqualsTest() { TimeRange timeRange1 = new TimeRange(start, end); TimeRange timeRange2 = new TimeRange(start, end); Assert.True(timeRange1.Equals(timeRange2)); TimeRange timeRange3 = new TimeRange(start.AddMilliseconds(-1), end.AddMilliseconds(1)); Assert.False(timeRange1.Equals(timeRange3)); } // EqualsTest
public void TimeRangeEqualityCheck() { var timeA = DateTime.Now; var timeB = timeA.AddSeconds(100); var range = new TimeRange(timeA, timeB); var other = new TimeRange(timeA, timeB); var not = new TimeRange(timeA, timeB.AddSeconds(10)); Assert.IsTrue(range.Equals(range)); Assert.IsTrue(range.Equals(other)); Assert.IsFalse(range.Equals(not)); Assert.IsFalse(range.Equals(null)); Assert.IsFalse(range.Equals(new object())); }
private void CurrentTimeRangeChanged(TimeRange newValue) { if (newValue.Equals(TimeRange.Night)) { Shared.EventSystem.SendNewWaveTrigger.Fire(); Shared.EventSystem.CurrentTimeRange.OnChangeEvent -= CurrentTimeRangeChanged; } }
public void Equals_SameValueIsEqual() { //Act var target = new TimeRange(new TimeSpan(1, 2, 3), new TimeSpan(10, 11, 12)); var actual = target.Equals(target); //Assert actual.Should().BeTrue(); }
public void Equals_DifferentRangesAreDifferent() { //Act var target1 = new TimeRange(new TimeSpan(1, 2, 3), new TimeSpan(10, 11, 12)); var target2 = new TimeRange(new TimeSpan(2, 3, 4), new TimeSpan(11, 12, 13)); var actual = target1.Equals(target2); //Assert actual.Should().BeFalse(); }
public void Equals_IdenticalRangesAreEqual() { var start = new TimeSpan(1, 2, 3); var end = new TimeSpan(10, 11, 12); //Act var target1 = new TimeRange(start, end); var target2 = new TimeRange(start, end); var actual = target1.Equals(target2); //Assert actual.Should().BeTrue(); }
public void Equals_GivenVariousScenarios_ReturnsAsExpected() { TimeRange first; TimeRange second; first = new TimeRange(null, null); second = new TimeRange(null, null); Assert.IsTrue(first.Equals(second)); first = new TimeRange(null, null); second = new TimeRange(new TimeSpan(), null); Assert.IsFalse(first.Equals(second)); var timeSpan = new TimeSpan(); first = new TimeRange(timeSpan, null); second = new TimeRange(timeSpan, null); Assert.IsTrue(first.Equals(second)); }
public bool Equals(DateTimeRange?other) => TimeRange.Equals(other);
protected void SetMinMax() { // 与bitmapObject不同,由于sb是纯静态的,所以可先判断出范围,为提高效率,这里先进行计算 if (_element.FadeList.Count > 0) { FadeTime = new TimeRange { Min = (int)_element.FadeList.Min(k => k.StartTime), Max = (int)_element.FadeList.Max(k => k.EndTime), }; F.Source = _element.FadeList.First().F1; F.Target = _element.FadeList.Last().F2; } if (_element.RotateList.Count > 0) { RotateTime = new TimeRange { Min = (int)_element.RotateList.Min(k => k.StartTime), Max = (int)_element.RotateList.Max(k => k.EndTime), }; Rad.Source = _element.RotateList.First().R1; Rad.Target = _element.RotateList.Last().R2; } if (_element.ScaleList.Count > 0) { VTime = new TimeRange { Min = (int)_element.ScaleList.Min(k => k.StartTime), Max = (int)_element.ScaleList.Max(k => k.EndTime) }; Vx.Source = _element.ScaleList.First().S1 *_vSize.Width; Vy.Source = _element.ScaleList.First().S1 *_vSize.Width; Vx.Target = _element.ScaleList.Last().S2 *_vSize.Height; Vy.Target = _element.ScaleList.Last().S2 *_vSize.Height; } if (_element.VectorList.Count > 0) { if (!VTime.Equals(TimeRange.Default)) { var tmpMin = (int)_element.VectorList.Min(k => k.StartTime); var tmpMax = (int)_element.VectorList.Max(k => k.EndTime); if (tmpMin < VTime.Min) { VTime.Min = tmpMin; Vx.Source = _element.VectorList.First().Vx1 *_vSize.Width; Vy.Source = _element.VectorList.First().Vy1 *_vSize.Height; } if (tmpMax > VTime.Max) { VTime.Max = tmpMax; Vx.Target = _element.VectorList.Last().Vx2 *_vSize.Width; Vy.Target = _element.VectorList.Last().Vy2 *_vSize.Height; } } else { VTime = new TimeRange { Min = (int)_element.VectorList.Min(k => k.StartTime), Max = (int)_element.VectorList.Max(k => k.EndTime) }; Vx.Source = _element.VectorList.First().Vx1 *_vSize.Width; Vy.Source = _element.VectorList.First().Vy1 *_vSize.Height; Vx.Target = _element.VectorList.Last().Vx2 *_vSize.Width; Vy.Target = _element.VectorList.Last().Vy2 *_vSize.Height; } } if (_element.MoveList.Count > 0) { MovTime = new TimeRange { Min = (int)_element.MoveList.Min(k => k.StartTime), Max = (int)_element.MoveList.Max(k => k.EndTime) }; X.Source = (_element.MoveList.First().X1 + 107) * _vSize.Width; Y.Source = _element.MoveList.First().Y1 *_vSize.Height; X.Target = (_element.MoveList.Last().X2 + 107) * _vSize.Width; Y.Target = _element.MoveList.Last().Y2 *_vSize.Height; } if (_element.MoveXList.Count > 0) { if (!MovTime.Equals(TimeRange.Default)) { var tmpMin = (int)_element.MoveXList.Min(k => k.StartTime); var tmpMax = (int)_element.MoveXList.Max(k => k.EndTime); if (tmpMin < MovTime.Min) { MovTime.Min = tmpMin; X.Source = (_element.MoveXList.First().X1 + 107) * _vSize.Width; } if (tmpMax > MovTime.Max) { MovTime.Max = tmpMax; X.Target = (_element.MoveXList.Last().X2 + 107) * _vSize.Width; } } else { MovTime = new TimeRange { Min = (int)_element.MoveXList.Min(k => k.StartTime), Max = (int)_element.MoveXList.Max(k => k.EndTime) }; X.Source = (_element.MoveXList.First().X1 + 107) * _vSize.Width; X.Target = (_element.MoveXList.Last().X2 + 107) * _vSize.Width; } } if (_element.MoveYList.Count > 0) { if (!MovTime.Equals(TimeRange.Default)) { var tmpMin = (int)_element.MoveYList.Min(k => k.StartTime); var tmpMax = (int)_element.MoveYList.Max(k => k.EndTime); if (tmpMin <= MovTime.Min) { MovTime.Min = tmpMin; Y.Source = _element.MoveYList.First().Y1 *_vSize.Height; } if (tmpMax >= MovTime.Max) { MovTime.Max = tmpMax; Y.Target = _element.MoveYList.Last().Y2 *_vSize.Height; } } else { MovTime = new TimeRange { Min = (int)_element.MoveYList.Min(k => k.StartTime), Max = (int)_element.MoveYList.Max(k => k.EndTime) }; Y.Source = _element.MoveYList.First().Y1 *_vSize.Height; Y.Target = _element.MoveYList.Last().Y2 *_vSize.Height; } } if (_element.ColorList.Count > 0) { CTime = new TimeRange { Min = (int)_element.ColorList.Min(k => k.StartTime), Max = (int)_element.ColorList.Max(k => k.EndTime) }; R.Source = _element.ColorList.First().R1; G.Source = _element.ColorList.First().G1; B.Source = _element.ColorList.First().B1; R.Target = _element.ColorList.Last().R2; G.Target = _element.ColorList.Last().G2; B.Target = _element.ColorList.Last().B2; } if (_element.ParameterList.Count > 0) { PTime = new TimeRange { Min = (int)_element.ParameterList.Min(k => k.StartTime), Max = (int)_element.ParameterList.Max(k => k.EndTime) }; } ResetRealTime(); }