public SmtpResponderFactory(IConfiguredSmtpRestrictions configuration, IEmailValidator emailValidator = null, IGetSmtpCapabilities getSmtpCapabilities = null) { if (configuration == null) throw new ArgumentNullException("configuration"); emailValidator = emailValidator ?? new XamarinEmailValidator(); getSmtpCapabilities = getSmtpCapabilities ?? new GetDefaultSmtpCapabilities(configuration); DataResponder = new SmtpDataResponder(configuration); IdentificationResponder = new SmtpIdentificationResponder(configuration, getSmtpCapabilities); MailFromResponder = new SmtpMailFromResponder(configuration, emailValidator); RecipientToResponder = new SmtpRecipientToResponder(configuration, emailValidator); RawLineResponder = new SmtpRawLineResponder(configuration); ResetResponder = new SmtpResetResponder(configuration); VerifyResponder = new SmtpVerifyResponder(configuration); }
public void EHLO_respond_with_capabilities() { var mockGetCapabilities = new Mock<IGetSmtpCapabilities>(); mockGetCapabilities.Setup(x => x.GetCapabilities()) .Returns(new[] { new SmtpCapability("CAP1", "param"), new SmtpCapability("CAP2"), new SmtpCapability("CAP3", "with parameter") }); var responder = new SmtpIdentificationResponder(new Mock<IConfiguredSmtpRestrictions>().Object, mockGetCapabilities.Object); var response = responder.VerifyIdentification(new Mock<ISmtpSessionInfo>().Object, new SmtpIdentification(SmtpIdentificationMode.EHLO, "localhost")); Assert.Equal(250, response.ResponseCode); Assert.Equal("CAP1 param", response.ResponseText); Assert.Equal("250-CAP2", response.AdditionalLines[0]); Assert.Equal("250-CAP3 with parameter", response.AdditionalLines[1]); }
public SmtpResponderFactory(IConfiguredSmtpRestrictions configuration, IEmailValidator emailValidator = null, IGetSmtpCapabilities getSmtpCapabilities = null) { if (configuration == null) { throw new ArgumentNullException("configuration"); } emailValidator = emailValidator ?? new XamarinEmailValidator(); getSmtpCapabilities = getSmtpCapabilities ?? new GetDefaultSmtpCapabilities(configuration); DataResponder = new SmtpDataResponder(configuration); IdentificationResponder = new SmtpIdentificationResponder(configuration, getSmtpCapabilities); MailFromResponder = new SmtpMailFromResponder(configuration, emailValidator); RecipientToResponder = new SmtpRecipientToResponder(configuration, emailValidator); RawLineResponder = new SmtpRawLineResponder(configuration); ResetResponder = new SmtpResetResponder(configuration); VerifyResponder = new SmtpVerifyResponder(configuration); }