public void Catching_argument_and_checking_manually_with_nfluent() { // Arrange PlainArgument arg = null; _fooService .DoStuff(Arg.Do <PlainArgument>(x => arg = x)); // Act _component.DoStuff(); // Assert _fooService.Received() .DoStuff(Arg.Any <PlainArgument>()); // passes Check.That(arg).HasFieldsWithSameValues( new PlainArgument( id: 7, firstName: "john", lastName: "doe", emailAddress: "*****@*****.**")); /* * // fails * Check.That(arg).HasFieldsWithSameValues( * new PlainArgument( * id: 11, * firstName: "jan", * lastName: "kowlaski", * emailAddress: "*****@*****.**")); * // */ }
public void Checking_argument_using_custom_NSubstitute_matcher() { // Arrange // Act _component.DoStuff(); // Assert // passes var expected = new PlainArgument( id: 7, firstName: "john", lastName: "doe", emailAddress: "*****@*****.**"); _fooService.Received() .DoStuff(WithArg.EquivalentTo(expected)); /* * // fails * var expected2 = new PlainArgument( * id: 11, * firstName: "jan", * lastName: "kowlaski", * emailAddress: "*****@*****.**"); * * _fooService.Received() * .DoStuff(WithArg.EquivalentTo(expected2)); * // */ }
public void Catching_argument_and_checking_manually_with_fluent_assertions() { // Arrange PlainArgument arg = null; _fooService .DoStuff(Arg.Do <PlainArgument>(x => arg = x)); // Act _component.DoStuff(); // Assert _fooService.Received() .DoStuff(Arg.Any <PlainArgument>()); // passes arg.Should() .BeEquivalentTo(new PlainArgument( id: 7, firstName: "john", lastName: "doe", emailAddress: "*****@*****.**")); /* * // fails * arg.Should() * .BeEquivalentTo(new PlainArgument( * id: 11, * firstName: "jan", * lastName: "kowlaski", * emailAddress: "*****@*****.**")); * // */ }