Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unit test c# exception thrown

// 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");
Source by fluentassertions.com #
 
PREVIOUS NEXT
Tagged: #unit #test #exception #thrown
ADD COMMENT
Topic
Name
1+5 =