public void Overlap_NullFirst_ThrowsException() { // Arrange DateTimeInterval first = null; var second = Fixture.Create <DateTimeInterval>(); // Act Action act = () => first.GetOverlapWith(second); // Assert act.Should().Throw <ArgumentNullException>().WithMessage("Value cannot be null.\r\nParameter name: first"); }
public void Overlap_Meets_Null() { // Arrange var(first, dateTime) = Fixture.Create <DateTimeInterval, LocalDateTime>((x, y) => x.End < y); var second = new DateTimeInterval(first.End, dateTime); // Act var overlap = first.GetOverlapWith(second); var overlapInverted = second.GetOverlapWith(first); // Assert overlap.Should().BeNull(); overlapInverted.Should().BeNull(); }
public void Overlap_Finishes_FinishingInterval() { // Arrange var(dateTime, first) = Fixture.Create <LocalDateTime, DateTimeInterval>((d, i) => d < i.Start); var second = new DateTimeInterval(dateTime, first.End); // Act var overlap = first.GetOverlapWith(second); var overlapInverted = second.GetOverlapWith(first); // Assert overlap.Should().Be(first); overlapInverted.Should().Be(first); ReferenceEquals(overlap, first).Should().BeFalse(); ReferenceEquals(overlapInverted, first).Should().BeFalse(); }
public void Overlap_Starts_StartingInterval() { // Arrange var(first, dateTime) = Fixture.Create <DateTimeInterval, LocalDateTime>((x, y) => x.End < y); var second = new DateTimeInterval(first.Start, dateTime); // Act var overlap = first.GetOverlapWith(second); var overlapInverted = second.GetOverlapWith(first); // Assert overlap.Should().Be(first); overlapInverted.Should().Be(first); ReferenceEquals(overlap, first).Should().BeFalse(); ReferenceEquals(overlapInverted, first).Should().BeFalse(); }
public static DateTimeInterval Overlap(this DateTimeInterval first, DateTimeInterval second) => first.GetOverlapWith(second);