public void When_the_execution_time_of_a_member_is_less_or_equal_to_a_limit_it_should_not_throw()
        {
            // Arrange
            var subject = new SleepingClass();

            // Act
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(0)).Should().BeLessOrEqualTo(500.Milliseconds());

            // Assert
            act.Should().NotThrow();
        }
        public void When_the_execution_time_of_a_member_is_greater_than_a_limit_it_should_not_throw()
        {
            // Arrange
            var subject = new SleepingClass();

            // Act
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(200)).Should().BeGreaterThan(100.Milliseconds());

            // Assert
            act.Should().NotThrow();
        }
        public void When_the_execution_time_of_a_member_is_close_to_a_limit_it_should_not_throw()
        {
            // Arrange
            var subject = new SleepingClass();

            // Act
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(210)).Should().BeCloseTo(200.Milliseconds(),
                                                                                             150.Milliseconds());

            // Assert
            act.Should().NotThrow();
        }
        public void When_the_execution_time_of_a_member_is_not_less_than_a_limit_it_should_throw()
        {
            // Arrange
            var subject = new SleepingClass();

            // Act
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(610)).Should().BeLessThan(500.Milliseconds(),
                                                                                              "we like speed");

            // Assert
            act.Should().Throw <XunitException>().WithMessage(
                "*(s.Sleep(610)) should be less than 0.500s because we like speed, but it required*");
        }
        public void When_the_execution_time_of_a_member_is_not_greater_than_a_limit_it_should_throw()
        {
            // Arrange
            var subject = new SleepingClass();

            // Act
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(100)).Should().BeGreaterThan(1.Seconds(),
                                                                                                 "we like speed");

            // Assert
            act.Should().Throw <XunitException>().WithMessage(
                "*(s.Sleep(100)) should be greater than 1s because we like speed, but it required*");
        }
        public void When_asserting_that_execution_time_is_close_to_a_negative_precision_it_should_throw()
        {
            // Arrange
            var subject = new SleepingClass();

            // Act
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(200)).Should().BeCloseTo(100.Milliseconds(),
                                                                                             -1.Ticks());

            // Assert
            act.Should().Throw <ArgumentOutOfRangeException>()
            .WithMessage("* value of precision must be non-negative*");
        }
        public void When_the_execution_time_of_a_member_is_not_close_to_a_limit_it_should_throw()
        {
            // Arrange
            var subject = new SleepingClass();

            // Act
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(200)).Should().BeCloseTo(100.Milliseconds(),
                                                                                             50.Milliseconds(),
                                                                                             "we like speed");

            // Assert
            act.Should().Throw <XunitException>().WithMessage(
                "*(s.Sleep(200)) should be within 0.050s from 0.100s because we like speed, but it required*");
        }
        public void When_the_execution_time_of_a_meber_stays_within_the_maximum_it_should_not_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new SleepingClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(0)).ShouldNotExceed(500.Milliseconds());

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
예제 #9
0
        public void When_the_execution_time_of_a_member_is_greater_or_equal_to_a_limit_it_should_not_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new SleepingClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(100)).Should().BeGreaterOrEqualTo(50.Milliseconds());

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.Should().NotThrow();
        }
예제 #10
0
        public void When_the_execution_time_of_a_member_is_less_than_a_limit_it_should_not_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new SleepingClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(0)).Should().BeLessThan(500.Milliseconds());

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.Should().NotThrow();
        }
        public void When_the_execution_time_of_a_meber_stays_within_the_maximum_it_should_not_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new SleepingClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(0)).ShouldNotExceed(500.Milliseconds());

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
        public void When_the_execution_time_of_a_member_exceeds_the_maximum_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new SleepingClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(610)).ShouldNotExceed(500.Milliseconds(), "we like speed");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act
            .ShouldThrow <AssertFailedException>()
            .And.Message.Should().StartWith(
                "Execution of (s.Sleep(610)) should not exceed 0.500s because we like speed, but it required 0.6");
        }
        public void When_the_execution_time_of_a_member_exceeds_the_maximum_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new SleepingClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(610)).ShouldNotExceed(500.Milliseconds(), "we like speed");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act
                .ShouldThrow<AssertFailedException>()
                .And.Message.Should().StartWith(
                    "Execution of (s.Sleep(610)) should not exceed 0.500s because we like speed, but it required 0.6");
        }
        public void When_the_execution_time_of_a_member_is_not_greater_or_equal_to_a_limit_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new SleepingClass();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ExecutionTimeOf(s => s.Sleep(100)).Should().BeGreaterOrEqualTo(1.Seconds(),
                                                                                                      "we like speed");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act
            .Should().Throw <XunitException>()
            .And.Message.Should().Match(
                "Execution of (s.Sleep(100)) should be greater or equal to 1s because we like speed, but it required*");
        }