本文整理汇总了C#中TimeRange.Move方法的典型用法代码示例。如果您正苦于以下问题:C# TimeRange.Move方法的具体用法?C# TimeRange.Move怎么用?C# TimeRange.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeRange
的用法示例。
在下文中一共展示了TimeRange.Move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsSamePeriodTest
public void IsSamePeriodTest() {
var timeRange1 = new TimeRange(_start, _end);
var timeRange2 = new TimeRange(_start, _end);
Assert.IsTrue(timeRange1.IsSamePeriod(timeRange1));
Assert.IsTrue(timeRange2.IsSamePeriod(timeRange2));
Assert.IsTrue(timeRange1.IsSamePeriod(timeRange2));
Assert.IsTrue(timeRange2.IsSamePeriod(timeRange1));
Assert.IsFalse(timeRange1.IsSamePeriod(TimeRange.Anytime));
Assert.IsFalse(timeRange2.IsSamePeriod(TimeRange.Anytime));
timeRange1.Move(new TimeSpan(1));
Assert.IsFalse(timeRange1.IsSamePeriod(timeRange2));
Assert.IsFalse(timeRange2.IsSamePeriod(timeRange1));
timeRange1.Move(new TimeSpan(-1));
Assert.IsTrue(timeRange1.IsSamePeriod(timeRange2));
Assert.IsTrue(timeRange2.IsSamePeriod(timeRange1));
}
示例2: MoveTest
public void MoveTest() {
var timeRangeMoveZero = new TimeRange(_start, _end);
timeRangeMoveZero.Move(TimeSpan.Zero);
timeRangeMoveZero.Start.Should().Be(_start);
timeRangeMoveZero.End.Should().Be(_end);
timeRangeMoveZero.Duration.Should().Be(duration);
var timeRangeMoveForward = new TimeRange(_start, _end);
var forwardOffset = new TimeSpan(2, 30, 15);
timeRangeMoveForward.Move(forwardOffset);
timeRangeMoveForward.Start.Should().Be(_start.Add(forwardOffset));
timeRangeMoveForward.End.Should().Be(_end.Add(forwardOffset));
timeRangeMoveForward.Duration.Should().Be(duration);
var timeRangeMoveBackward = new TimeRange(_start, _end);
var backwardOffset = new TimeSpan(-1, 10, 30);
timeRangeMoveBackward.Move(backwardOffset);
timeRangeMoveBackward.Start.Should().Be(_start.Add(backwardOffset));
timeRangeMoveBackward.End.Should().Be(_end.Add(backwardOffset));
timeRangeMoveBackward.Duration.Should().Be(duration);
}