Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        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);