public void It_should_Be_Accept_A_Starting_Tick_Count() { var original = DateTime.UtcNow; var target = new InterlockedDateTime(original.Ticks); target.GetValue().Should().Be(original); target.Equals(original).Should().BeTrue(); target.Equals(new InterlockedDateTime(original)).Should().BeTrue(); }
public void It_should_Be_Comparable_To_Earlier_And_Later_Values() { var now = DateTime.UtcNow; var before = now.AddDays(-1); var after = now.AddDays(1); var target = new InterlockedDateTime(now); target.GetValue().Should().Be(now); target.Should().Be(new InterlockedDateTime(now)); (target >= before).Should().BeTrue(); (before <= target).Should().BeTrue(); (target >= new InterlockedDateTime(before)).Should().BeTrue(); (new InterlockedDateTime(before) <= target).Should().BeTrue(); (target > before).Should().BeTrue(); (before < target).Should().BeTrue(); (target > new InterlockedDateTime(before)).Should().BeTrue(); (new InterlockedDateTime(before) < target).Should().BeTrue(); (target == now).Should().BeTrue(); (now == target).Should().BeTrue(); (target == new InterlockedDateTime(now)).Should().BeTrue(); (new InterlockedDateTime(now) == target).Should().BeTrue(); (target != after).Should().BeTrue(); (after != target).Should().BeTrue(); (target != new InterlockedDateTime(after)).Should().BeTrue(); (new InterlockedDateTime(after) != target).Should().BeTrue(); (target <= before).Should().BeFalse(); (before >= target).Should().BeFalse(); (target <= new InterlockedDateTime(before)).Should().BeFalse(); (new InterlockedDateTime(before) >= target).Should().BeFalse(); (target < before).Should().BeFalse(); (before > target).Should().BeFalse(); (target < new InterlockedDateTime(before)).Should().BeFalse(); (new InterlockedDateTime(before) > target).Should().BeFalse(); target.As <IComparable <DateTime> >().Should().BeGreaterThan(before); target.As <IComparable <DateTime> >().Should().BeLessThan(after); target.As <IComparable <InterlockedDateTime> >().Should().BeGreaterThan(new InterlockedDateTime(before)); target.CompareTo(before).Should().BeGreaterThan(0); }