Hi. I'm having trouble with (this really cool feature) Natural Mocks.
I am trying to Mock the MailMessage class in order to verify it's parameters. I intend to let it continue, I only want to see if the parameters are correct. So I wrote the following:
using (RecordExpectations r = RecorderManager.StartRecording())
{
MailMessage mail = new MailMessage("me@foo.bar","you@foo.bar", "a subject", "my body");
r.CallOriginal();
r.CheckArguments();
}
I expect that this will verify the arguments are as they are typed in the test, and then proceed to call the real MailMessage constructor.
The problem is that TypeMock seems to catch a MailMessage(string, string). It eventually throws a TypeMock exception stating that it caught a call to MailMessage with only 2 parameters when it actually expected four.
using r.Repeat(1) didn't help.
Adding a check for "new MailMessage("me@foo.bar", "you@foo.bar") fixed the problem. Looks like MailMessage uses constructor chaining. It seems to me that I shouldn't have to be aware of that; TypeMock should ignore the chained constructor.
What am I doing wrong or how do I get TypeMock to ignore the second constructor call?
Thanks for the help!
BTW.. Natural Mocks: very cool.
________
TEEN VIDEOS