public void TestInitialize() { using (ShimsContext.Create()) { var ehloLines = new List <Func <SMTPTransaction, string> >(); AddCoreListProperty("EHLOLines", () => ehloLines); var loader = new StubIAuthMethodLoader { GetModules = () => new List <Tuple <string, IAuthMethod> > { new Tuple <string, IAuthMethod>("Test", new StubIAuthMethod()), new Tuple <string, IAuthMethod>("Something", new StubIAuthMethod()) } }; var handler = new AUTHHandler(loader); handler.Initialize(Core); Assert.Contains("AUTH TEST SOMETHING", ehloLines.Select(e => e(Transaction))); } }
public void TestExecutSuccess(string parameters, string expectedDecoded) { using (ShimsContext.Create()) { AddTransactionProperty("Authenticated", false); AddCoreListProperty("EHLOLines", new List <Func <SMTPTransaction, string> >()); SMTPTransaction actualTransaction = null; string decodedReponse = null; IAuthMethod actualAuthMethod = null; var expectedResponse = new SMTPResponse(SMTPStatusCode.Okay); ShimAUTHHandler.HandleResponseSMTPTransactionStringIAuthMethod = (transaction, data, authMethod) => { actualTransaction = transaction; decodedReponse = data; actualAuthMethod = authMethod; return(expectedResponse); }; var method = new StubIAuthMethod(); var loader = new StubIAuthMethodLoader { GetModules = () => new List <Tuple <string, IAuthMethod> > { new Tuple <string, IAuthMethod>("TEST", method) } }; var handler = new AUTHHandler(loader); handler.Initialize(Core); var response = handler.DoExecute(Transaction, parameters); Assert.Same(method, actualAuthMethod); Assert.Same(expectedResponse, response); Assert.Equal(Transaction, actualTransaction); Assert.Equal(expectedDecoded, decodedReponse); } }
public void TestExecuteSyntaxError(string parameters) { using (ShimsContext.Create()) { AddTransactionProperty("Authenticated", false); AddCoreListProperty("EHLOLines", new List <Func <SMTPTransaction, string> >()); var method = new StubIAuthMethod(); var loader = new StubIAuthMethodLoader { GetModules = () => new List <Tuple <string, IAuthMethod> > { new Tuple <string, IAuthMethod>("TEST", method) } }; var handler = new AUTHHandler(loader); handler.Initialize(Core); var response = handler.DoExecute(Transaction, parameters); Assert.Equal(SMTPStatusCode.SyntaxError, response.Code); } }