fluentassertions force exceptions

Code Example - fluentassertions force exceptions

                
                        subject.Invoking(y => y.Foo("Hello"))
    .Should().Throw<InvalidOperationException>()
    .WithMessage("Hello is not allowed at this moment");
                    
                
 

fluent assertions exception

                        
                                // fluent syntax
subject.Invoking(y => y.Foo(null))
    .Should().Throw<ArgumentNullException>();

// arrange-act-assert syntax
Action callingFooWithNull = () => subject.Foo(null);

callingFooWithNull.Should().Throw<ArgumentNullException>()
    .WithParameterName("message");
                            
                        
 

Related code examples