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.ShouldBeEquivalentTo(expected, opts => opts.Using <object>(context => { throw new Exception(); }) .When(s => true) .Using <object>(context => { }) .When(s => true)); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act.ShouldNotThrow( "a different assertion rule should handle the comparision before the exception throwing assertion rule is hit"); }
public void When_multiple_equivalency_steps_are_added_they_should_be_executed_from_right_to_left() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ClassWithOnlyAProperty(); var expected = new ClassWithOnlyAProperty(); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.ShouldBeEquivalentTo(expected, opts => opts.Using(new ThrowExceptionEquivalencyStep <NotSupportedException>()) .Using(new ThrowExceptionEquivalencyStep <InvalidOperationException>())); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act.ShouldThrow <NotSupportedException>(); }
public void When_an_equivalency_does_not_handle_the_comparison_later_equivalency_steps_should_stil_be_ran() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ClassWithOnlyAProperty(); var expected = new ClassWithOnlyAProperty(); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.ShouldBeEquivalentTo(expected, opts => opts.Using(new NeverHandleEquivalencyStep()) .Using(new ThrowExceptionEquivalencyStep <InvalidOperationException>())); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act.ShouldThrow <InvalidOperationException>(); }