/// <summary> /// Starts server listening to the specified port with a simulated delay when processing a new SMTP message. /// </summary> /// <param name="port">The port.</param> /// <param name="processingDelayInMilliseconds">The number of milliseconds to wait before processing a new SMTP message</param> /// <returns></returns> public static SimpleSmtpServer Start(int port, int processingDelayInMilliseconds) { return(SimpleSmtpServer.Start(Configuration.Configure() .WithPort(port) .WithProcessingDelay(processingDelayInMilliseconds) )); }
public static void StopEmailServer(SimpleSmtpServer server) { if(server != null) { server.Stop(); } }
internal static SimpleSmtpServer Start(Configuration configuration) { var server = new SimpleSmtpServer(configuration); new Thread(new ThreadStart(server.StartListening)).Start(); server.ServerReady.WaitOne(); return(server); }
/// <summary> /// Starts server at the specified port. /// </summary> /// <param name="port">The port.</param> /// <returns></returns> public static SimpleSmtpServer Start(int port) { var server = new SimpleSmtpServer(port); new Thread(new ThreadStart(server._Start)).Start(); server._serverReady.WaitOne(); return(server); }
private LocalMailServer(int port) { _completion = new TaskCompletionSource<string>(); _timeoutCancelationToken = new CancellationTokenSource(); _server = SimpleSmtpServer.Start(port); _server.MessageReceived += OnMessageReceived; }
/// <summary> /// Builds this instance. /// </summary> /// <returns></returns> public SimpleSmtpServer Build() { Configuration config = this; if (this.Port == 0) { config = this.WithRandomPort(); } return(SimpleSmtpServer.Start(config)); }
public static void InitTests(TestContext context) { const int DEFAULT_PORT = 2773; Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); MailSettingsSectionGroup mailSettings = config.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup; int port; if (mailSettings != null) { port = mailSettings.Smtp.Network.Port; } else { port = DEFAULT_PORT; } _server = SimpleSmtpServer.Start(port); }
public void Preparations() { if (TestConfig.UseExistingInstallation) { return; } var applicationPath = Path.Combine(TestConfig.InstallPhysicalPath, TestConfig.TestApplicationName); // Delete folder if (Directory.Exists(applicationPath)) { Directory.Delete(applicationPath, true); } // Create folder Directory.CreateDirectory(TestConfig.InstallPhysicalPath); var installZip = string.Empty; switch (TestConfig.PackageLocation) { case "Local": { installZip = TestConfig.LocalReleasePackageFile; } break; case "CodePlex": { installZip = Path.Combine(TestConfig.InstallPhysicalPath, "YAF-BIN.zip"); // download latest release var webClient = new WebClient(); webClient.DownloadFile(TestConfig.ReleaseDownloadUrl, installZip); webClient.Dispose(); } break; } // Exctract Install Package var fastZip = new FastZip(); fastZip.ExtractZip( installZip, applicationPath, FastZip.Overwrite.Always, null, null, "YetAnotherForum.NET", false); foreach ( string dirPath in Directory.GetDirectories( Path.Combine(applicationPath, "YetAnotherForum.NET"), "*", SearchOption.AllDirectories)) { Directory.CreateDirectory( dirPath.Replace(Path.Combine(applicationPath, "YetAnotherForum.NET"), applicationPath)); } foreach ( string newPath in Directory.GetFiles( Path.Combine(applicationPath, "YetAnotherForum.NET"), "*.*", SearchOption.AllDirectories)) { File.Move( newPath, newPath.Replace(Path.Combine(applicationPath, "YetAnotherForum.NET"), applicationPath)); } Directory.Delete(Path.Combine(applicationPath, "YetAnotherForum.NET"), true); // Rename Web.config File.Copy( Path.Combine(applicationPath, "recommended-NET-web.config"), Path.Combine(applicationPath, "web.config")); // Create Website in IIS IISManager.CreateIISApplication(TestConfig.TestApplicationName, applicationPath); // Add Config Password XmlDocument xmlAppConfig = new XmlDocument(); xmlAppConfig.Load(Path.Combine(applicationPath, "app.config")); XmlNode xNode = xmlAppConfig.CreateNode(XmlNodeType.Element, "add", string.Empty); XmlAttribute xKey = xmlAppConfig.CreateAttribute("key"); XmlAttribute xValue = xmlAppConfig.CreateAttribute("value"); xKey.Value = "YAF.ConfigPassword"; xValue.Value = TestConfig.ConfigPassword; xNode.Attributes.Append(xKey); xNode.Attributes.Append(xValue); xmlAppConfig.GetElementsByTagName("appSettings")[0].InsertAfter( xNode, xmlAppConfig.GetElementsByTagName("appSettings")[0].LastChild); xmlAppConfig.Save(Path.Combine(applicationPath, "app.config")); // Setup Mail Config var xmlMailConfig = new XmlDocument(); xmlMailConfig.Load(Path.Combine(applicationPath, "mail.config")); XmlNode xNetworkNode = xmlMailConfig.CreateNode(XmlNodeType.Element, "network", string.Empty); var xhost = xmlMailConfig.CreateAttribute("host"); var xport = xmlMailConfig.CreateAttribute("port"); var xpassword = xmlMailConfig.CreateAttribute("password"); var xuserName = xmlMailConfig.CreateAttribute("userName"); xhost.Value = TestConfig.TestMailHost; xport.Value = TestConfig.TestMailPort; xpassword.Value = TestConfig.TestMailPassword; xuserName.Value = TestConfig.TestMailUserName; xNetworkNode.Attributes.Append(xhost); xNetworkNode.Attributes.Append(xport); xNetworkNode.Attributes.Append(xpassword); xNetworkNode.Attributes.Append(xuserName); xmlMailConfig.GetElementsByTagName("smtp")[0].InsertAfter( xNetworkNode, xmlMailConfig.GetElementsByTagName("smtp")[0].LastChild); xmlMailConfig.GetElementsByTagName("smtp")[0].Attributes["from"].Value = TestConfig.TestForumMail; xmlMailConfig.Save(Path.Combine(applicationPath, "mail.config")); // Inject Custom.sql file File.Copy(@"..\..\testfiles\custom.sql", Path.Combine(applicationPath, "install\\custom.sql")); if (TestConfig.UseTestMailServer) { // Launch Mail Server SmtpServer = SimpleSmtpServer.Start(TestConfig.TestMailPort.ToType<int>()); } // Setup DB DBManager.AttachDatabase(TestConfig.TestDatabase, Path.Combine(applicationPath, "App_Data\\Database.mdf")); this.SetupWebsite(); }
public void FixtureSetUp() { _Server = SimpleSmtpServer.Start(_Rnd.Next(50000, 60000)); }
internal static SimpleSmtpServer Start(Configuration configuration) { var server = new SimpleSmtpServer(configuration); new Thread(new ThreadStart(server.StartListening)).Start(); server.ServerReady.WaitOne(); return server; }
public void Init() { // Assign the fake smtp port _port = _portRand.Next(50000, 60000); // Starts up the fake smtp server. _smtpServer = SimpleSmtpServer.Start(_port); // Gets the current executing version of NAnt to use for some // of the test emails. _nantVersion = Assembly.GetExecutingAssembly().GetName().Version; // Setup the temp directory _tempPath = Path.Combine(Path.GetTempPath(), "NAntEmailTesting"); if (!Directory.Exists(_tempPath)) { Directory.CreateDirectory(_tempPath); } // Create temp files containing messages to load for testing. The // resulting paths are stored in a List<string> var for location // purposes. _files = new List<string>(3); _files.Add(CreateEmailMessageTempFile("NAntMailFile1.txt")); _files.Add(CreateEmailMessageTempFile("NAntMailFile2.txt")); _files.Add(CreateEmailMessageTempFile("NAntMailFile3.txt")); }
/// <summary> /// Starts the specified port. /// </summary> /// <param name="port">The port.</param> /// <param name="useMessageStore">if set to <c>true</c> [use message store].</param> /// <returns></returns> public static SimpleSmtpServer Start(int port, bool useMessageStore) { return(SimpleSmtpServer.Start(Configuration.Configure().WithPort(port).EnableMessageStore(useMessageStore))); }
public static void InitTests(TestContext context) { const int PORT = 2773; _server = SimpleSmtpServer.Start(PORT); }
/// <summary> /// Starts the specified use message store. /// </summary> /// <param name="useMessageStore">if set to <c>true</c> [use message store].</param> /// <returns></returns> public static SimpleSmtpServer Start(bool useMessageStore) { return(SimpleSmtpServer.Start(Configuration.Configure().WithRandomPort().EnableMessageStore(useMessageStore))); }
/// <summary> /// Starts server listening to the specified port. /// </summary> /// <param name="port">The port.</param> /// <returns></returns> public static SimpleSmtpServer Start(int port) { return(SimpleSmtpServer.Start(port, true)); }
public void FixtureSetUp() { this._server = SimpleSmtpServer.Start(25000); }
public void SetUp() { this.server = this.StartServer(); }
public void SetUp() { _Server = SimpleSmtpServer.Start(_Rnd.Next(50000, 60000)); _Server.ClearReceivedEmail(); }
/// <summary> /// Starts the specified port. /// </summary> /// <param name="port">The port.</param> /// <param name="useMessageStore">if set to <c>true</c> [use message store].</param> /// <returns></returns> public static SimpleSmtpServer Start(int port, bool useMessageStore) { return(SimpleSmtpServer.Start(port, useMessageStore, 0)); }
/// <summary> /// Starts server listening to the specified port. /// </summary> /// <param name="port">The port.</param> /// <returns></returns> public static SimpleSmtpServer Start(int port) { return(SimpleSmtpServer.Start(Configuration.Configure().WithPort(port))); }
public static void InitClass(TestContext testContext) { _Server = SimpleSmtpServer.Start(10025); }
/// <summary> /// Starts the specified port. /// </summary> /// <param name="port">The port.</param> /// <param name="useMessageStore">if set to <c>true</c> [use message store].</param> /// <param name="processingDelayInMilliseconds">The number of milliseconds to wait before processing a new SMTP message</param> /// <returns></returns> public static SimpleSmtpServer Start(int port, bool useMessageStore, int processingDelayInMilliseconds) { return(SimpleSmtpServer.Start(Configuration.Configure().WithPort(port).EnableMessageStore(useMessageStore).WithProcessingDelay(processingDelayInMilliseconds))); }
/// <summary> /// Starts server at the specified port. /// </summary> /// <param name="port">The port.</param> /// <returns></returns> public static SimpleSmtpServer Start(int port) { var server = new SimpleSmtpServer(port); new Thread(new ThreadStart(server.StartListening)).Start(); server.ServerReady.WaitOne(); return server; }
/// <summary> /// Starts this instance. /// </summary> /// <returns></returns> public static SimpleSmtpServer Start() { return(SimpleSmtpServer.Start(Configuration.Configure().WithRandomPort())); }
public void SetUp() { server = SimpleSmtpServer.Start(_Rnd.Next(50000, 60000)); }
public void Setup() { // Create an SMTP client to get the port specified in app.config SmtpClient client = new SmtpClient(); _server = SimpleSmtpServer.Start(client.Port); }