public void TestPortOpening() { Application oApp = SingletonProvider<TestSetup>.Instance.GetApp(); oApp.Settings.TCPIPPorts.SetDefault(); var pSMTPSimulator = new SMTPClientSimulator(); var pPOP3Simulator = new POP3Simulator(); var pIMAPSimulator = new IMAPSimulator(); oApp.Stop(); TCPIPPorts oPorts = oApp.Settings.TCPIPPorts; for (int i = 0; i < oPorts.Count; i++) { TCPIPPort oTestPort = oPorts[i]; if (oTestPort.Protocol == eSessionType.eSTIMAP) oTestPort.PortNumber = 14300; else if (oTestPort.Protocol == eSessionType.eSTSMTP) oTestPort.PortNumber = 11000; else if (oTestPort.Protocol == eSessionType.eSTPOP3) oTestPort.PortNumber = 2500; oTestPort.Save(); } oApp.Start(); CustomAssert.IsTrue(pSMTPSimulator.TestConnect(2500)); CustomAssert.IsTrue(pSMTPSimulator.TestConnect(11000)); CustomAssert.IsTrue(pSMTPSimulator.TestConnect(14300)); oApp.Stop(); TCPIPPort oPort = oApp.Settings.TCPIPPorts.Add(); oPort.Protocol = eSessionType.eSTSMTP; oPort.PortNumber = 25000; oPort.Save(); oApp.Start(); // Try to connect to the new port CustomAssert.IsTrue(pSMTPSimulator.TestConnect(25000)); oApp.Stop(); // Delete the port again oApp.Settings.TCPIPPorts.DeleteByDBID(oPort.ID); // Change back the ports for (int i = 0; i < oPorts.Count; i++) { TCPIPPort oTestPort = oPorts[i]; if (oTestPort.Protocol == eSessionType.eSTIMAP) oTestPort.PortNumber = 143; else if (oTestPort.Protocol == eSessionType.eSTSMTP) oTestPort.PortNumber = 25; else if (oTestPort.Protocol == eSessionType.eSTPOP3) oTestPort.PortNumber = 110; oTestPort.Save(); } oApp.Start(); CustomAssert.IsTrue(pSMTPSimulator.TestConnect(25)); CustomAssert.IsTrue(pPOP3Simulator.TestConnect(110)); CustomAssert.IsTrue(pPOP3Simulator.TestConnect(143)); }