I'm having problems with a test. For some reason, that I haven't figured out, I can't access a n object's public property.
My class is the following:
public class FakeSMTPConnector : ISMTPConnector
{
private bool _MailSent = false;
public bool MailSent
{
get { return _MailSent; }
set { _MailSent = value; }
}
private MailMessage _Message = null;
public MailMessage Message
{
get { return _Message; }
set { _Message = value; }
}
public FakeSMTPConnector()
{
}
public void SendMail(MailMessage mail)
{
_MailSent = true;
_Message = mail;
}
}
I'm using this to simulate an SMTPConnection and send an email message. A class that handles email messages will then use this SMTPconnector to fake the delivery.
My test is as follows:
[Test]
public void EnviarMensagemContactoSentTest()
{
//arrange
FakeSMTPConnector connector = new FakeSMTPConnector();
EmailManager manager = new EmailManager(connector);
//act
manager.SendMessage("a@a.com", "abc", "def", "ghi");
//assert
Assert.IsNotNull(manager, "Manager instance not created");
Assert.IsTrue(connector.MailSent, "Message not sent");
Assert.IsNotNull(connector.Message);
}
When Nunit attempts the last assert, that acesses the Message property, it fails with an exception that doesn't make much sense:
System.MissingMethodException : Method not found: 'System.Net.Mail.MailMessage Project.FakeSMTPConnector.get_Message()'.
Am I doing anything wrong? I'm getting started adding tests and doing some refoactoring on a project so alot of this is kinda new and might be that I'm making somee confusion onsomething real basic up in my head...
Thanks!