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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I have this

my_Accessor target = new my_Accessor();
DateTime dtMax = new DateTime(2008, 10, 1, 15, 17, 0);
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
// CAUTION: ALL calls here are mocked!!!
// mock PrivateMethod
dtMax = target.InUTCTime(dtMax, 1, 1, 1);
recorder.Return(new DateTime(1999, 10, 1, 19, 18, 02));
}

in the target source, I have something like this


DateTime localDtNow = InUTCTime(dtNow, SomeClass.Prop1, SomClass.prop2, SomClass.Prop3);

I would expect a call to this inUTCTime will be faked, but instead, it doesn't and it return an error complaining the somclass is not setup .

a simple call to InUtcTime(DtNow, 1,1,11) will work
asked by ben1628 (2k points)

1 Answer

0 votes
Hi Ben,

Does target.InUTCTime have several overloads? in any case I suggest that you use the (newer) AAA api instead:
my_Accessor target = new my_Accessor(); 
DateTime dtMax = new DateTime(2008, 10, 1, 15, 17, 0); 

// The arguments values does not matter unless you use WithExactArguments
Isolate.WhenCalled(() => target.InUTCTime(dtMax, 0, 0, 0)).WillReturn(new DateTime(1999, 10, 1, 19, 18, 02));
answered by dhelper (11.9k points)
...