Answers for "fluent assertions should throw"

C#
1

fluentassertions force exceptions

subject.Invoking(y => y.Foo("Hello"))
    .Should().Throw<InvalidOperationException>()
    .WithMessage("Hello is not allowed at this moment");
Posted by: Guest on August-17-2020
0

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");
Posted by: Guest on February-24-2022

C# Answers by Framework

Browse Popular Code Answers by Language