Say if i had the following interface mocked in (NMock). How could i check that email.Subject = 'xyz' ?
Currently im doing something like
IEmailService s = mocks.NewMock<IEmailService>();
Expect.Once.On(s).Method("Send").With(?????)
s.Send(new Email { Subject = 'rarr' });
mocks.Verify...();
interface EmailService { void SendEmail(Email email); }
You can use a Has.Property
matcher like this:
IEmailService s = mocks.NewMock<IEmailService>();
Expect.Once.On(s).Method("Send").
With(Has.Property("Subject", Is.EqualTo("rarr")));
s.Send(new Email { Subject = 'rarr' });
mocks.Verify...();
Or you could write a custom matcher to verify that the argument is of the type Email
and that its Subject
property has the correct value.