コード例 #1
0
        public void When_multiple_asertion_rules_are_added_with_the_fluent_api_they_should_be_executed_from_right_to_left()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject  = new ClassWithOnlyAProperty();
            var expected = new ClassWithOnlyAProperty();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act =
                () =>
                subject.Should().BeEquivalentTo(expected,
                                                opts =>
                                                opts.Using <object>(context => throw new Exception())
                                                .When(s => true)
                                                .Using <object>(context => { })
                                                .When(s => true));

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.Should().NotThrow(
                "a different assertion rule should handle the comparison before the exception throwing assertion rule is hit");
        }
コード例 #2
0
        public void When_multiple_equivalency_steps_are_added_they_should_be_executed_in_registration_order()
        {
            // Arrange
            var subject  = new ClassWithOnlyAProperty();
            var expected = new ClassWithOnlyAProperty();

            // Act
            Action act =
                () =>
                subject.Should().BeEquivalentTo(expected,
                                                opts =>
                                                opts.Using(new ThrowExceptionEquivalencyStep <NotSupportedException>())
                                                .Using(new ThrowExceptionEquivalencyStep <InvalidOperationException>()));

            // Assert
            act.Should().Throw <NotSupportedException>();
        }
コード例 #3
0
        public void When_an_equivalency_does_not_handle_the_comparison_later_equivalency_steps_should_still_be_ran()
        {
            // Arrange
            var subject  = new ClassWithOnlyAProperty();
            var expected = new ClassWithOnlyAProperty();

            // Act
            Action act =
                () =>
                subject.Should().BeEquivalentTo(expected,
                                                opts =>
                                                opts.Using(new NeverHandleEquivalencyStep())
                                                .Using(new ThrowExceptionEquivalencyStep <InvalidOperationException>()));

            // Assert
            act.Should().Throw <InvalidOperationException>();
        }
コード例 #4
0
        public void When_an_equivalency_step_handles_the_comparison_later_equivalency_steps_should_not_be_ran()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject  = new ClassWithOnlyAProperty();
            var expected = new ClassWithOnlyAProperty();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act =
                () =>
                subject.Should().BeEquivalentTo(expected,
                                                opts =>
                                                opts.Using(new AlwayHandleEquivalencyStep())
                                                .Using(new ThrowExceptionEquivalencyStep <InvalidOperationException>()));

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.Should().NotThrow();
        }