public async Task Process_MissingAddress_ErrorResponse() { Mocks mocks = new Mocks(); MailFromVerb mailFromVerb = new MailFromVerb(); await mailFromVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("FROM")); mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.SyntaxErrorInCommandArguments); }
public async Task Process_AlreadyGivenFrom_ErrorResponse() { Mocks mocks = new Mocks(); mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(new Mock <IMessageBuilder>().Object); MailFromVerb mailFromVerb = new MailFromVerb(); await mailFromVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("FROM <*****@*****.**>")); mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.BadSequenceOfCommands); }
private async Task Process_AddressAsync(string address, string expectedParsedAddress, StandardSmtpResponseCode expectedResponse) { Mocks mocks = new Mocks(); Mock <IMessageBuilder> message = new Mock <IMessageBuilder>(); IMessageBuilder currentMessage = null; mocks.Connection.Setup(c => c.NewMessage()).Returns(() => { currentMessage = message. Object; return (currentMessage); }); mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(() => currentMessage); MailFromVerb mailFromVerb = new MailFromVerb(); await mailFromVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("FROM " + address)); mocks.VerifyWriteResponseAsync(expectedResponse); message.VerifySet(m => m.From = expectedParsedAddress); }