Another question on MustBeCalled. Is there a way to assert a partial match of an argument?
For example, the first argument of the call to be asserted is an object which has 10 properties but I only care about 2 of them in the particular test case.
Thanks!
A failed attempt/example:
var accounts = ...
var target = Mock.Create<TargetClass>(Behavior.CallOriginal, accounts);
Mock.Arrange(() => target.TestCall(Arg.IsAny<Account>()).DoNothing();
target.Run(); // Will call internal TestCall for each account
foreach(var account in accounts)
Mock.Assert(() => target.TestCall(Arg.Matches<Account>(x => x.FirstName == account.FirstName && x.LastName == account.LastName), Occurs.Once());
Error is: Expected TargetClass.TestCall(Accoutn) call on the mock should be once, but it was called 0 times(s).
Any suggestion, please?
For example, the first argument of the call to be asserted is an object which has 10 properties but I only care about 2 of them in the particular test case.
Thanks!
A failed attempt/example:
var accounts = ...
var target = Mock.Create<TargetClass>(Behavior.CallOriginal, accounts);
Mock.Arrange(() => target.TestCall(Arg.IsAny<Account>()).DoNothing();
target.Run(); // Will call internal TestCall for each account
foreach(var account in accounts)
Mock.Assert(() => target.TestCall(Arg.Matches<Account>(x => x.FirstName == account.FirstName && x.LastName == account.LastName), Occurs.Once());
Error is: Expected TargetClass.TestCall(Accoutn) call on the mock should be once, but it was called 0 times(s).
Any suggestion, please?