chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
Hi guys,

I'm trying to use natural mocks as follows (DmsService just wraps calls to a 3rd party lib):

SearchConditionSet expectedSearchConditions =
CreateExpectedSearchConditions(DOC_ID, DOC_VERSION);


using (RecordExpectations recorder = RecorderManager.StartRecording())
{
recorder.ExpectAndReturn(
DmsService.FindDocuments(
TRADE_CATEGORY,
expectedSearchConditions),
metaData);

recorder.CheckArguments(Check.IsAny(),
Check.CustomChecker(new
ParameterCheckerEx(CheckSearchConditions),
expectedSearchConditions,
"SearchConditionsDidNotMatch"));
}


and my delegate is

public static bool CheckSearchConditions(
ParameterCheckerEventArgs args)
{
SearchConditionSet actual = (SearchConditionSet)
args.ArgumentValue;
SearchConditionSet expected = (SearchConditionSet)
args.ExpectedValue;

//compare properties...

}

My issue is that my delegate is not called, and I get an error that the passed object is not the same instance as expected. Now the comparison appears to have been done on identity.

Now, I don't want to compare identity, I want to compare the value as I know that the calling code does not use the expectedSearchConditions but something that is equivalent in value.

I expected Check.CustomChecker to allow this, but it appears to be implicitly checking the identity of the argument.

Am I missing something?
asked by IanCooper (600 points)

1 Answer

0 votes
Hi
Few questions:
1. Its not clear who sends the error. Can you please post the full error message?
2. If the delegate is not called who is doing the comparison on identity?

If its possible please post the full code of CheckSearchConditions method.
answered by ohad (35.4k points)
...