当前位置: 首页>>代码示例>>C#>>正文


C# Shared.SmtpClientSimulator类代码示例

本文整理汇总了C#中RegressionTests.Shared.SmtpClientSimulator的典型用法代码示例。如果您正苦于以下问题:C# SmtpClientSimulator类的具体用法?C# SmtpClientSimulator怎么用?C# SmtpClientSimulator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SmtpClientSimulator类属于RegressionTests.Shared命名空间,在下文中一共展示了SmtpClientSimulator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestDistributionListModeAnnouncer

        public void TestDistributionListModeAnnouncer()
        {
            var recipients = new List<string>();
             recipients.Add("[email protected]");
             recipients.Add("[email protected]");
             recipients.Add("[email protected]");

             var list = SingletonProvider<TestSetup>.Instance.AddDistributionList(_domain, "[email protected]", recipients);

             SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
             SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
             SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             var announcer = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             // Switch list mode so that only a single announcer can send to list.
             list.Mode = eDistributionListMode.eLMAnnouncement;
             list.RequireSenderAddress = announcer.Address;
             list.RequireSMTPAuth = false;
             list.Save();

             var smtpClient = new SmtpClientSimulator();
             CustomAsserts.Throws<DeliveryFailedException>(() => smtpClient.Send("[email protected]", list.Address, "Mail 1", "Mail 1"));
             smtpClient.Send(announcer.Address, list.Address, "Mail 1", "Mail 1");

             foreach (var recipient in recipients)
            ImapClientSimulator.AssertMessageCount(recipient, "test", "Inbox", 1);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:28,代码来源:DistributionLists.cs

示例2: TestDomainAliases

        public void TestDomainAliases()
        {
            // Create a test account
             // Fetch the default domain
             DomainAlias oDomainAlias = _domain.DomainAliases.Add();
             oDomainAlias.AliasName = "alias.com";
             oDomainAlias.Save();

             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]",
                                                                             "test");

             // Send 5 messages to this account.
             var smtpClientSimulator = new SmtpClientSimulator();
             for (int i = 0; i < 5; i++)
            smtpClientSimulator.Send("[email protected]", "[email protected]", "INBOX", "Alias test message");

             Pop3ClientSimulator.AssertMessageCount("[email protected]", "test", 5);

             {
            oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain,
                                                                        "[email protected]", "test");

            // Set up an alias pointing at the domain alias.
            SingletonProvider<TestSetup>.Instance.AddAlias(_domain, "[email protected]",
                                                           "[email protected]");

            // Send to the alias
            for (int i = 0; i < 5; i++)
               smtpClientSimulator.Send(oAccount.Address, "[email protected]", "INBOX", "Plus addressing message");
            // Wait for completion

            Pop3ClientSimulator.AssertMessageCount(oAccount.Address, "test", 5);
             }
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:34,代码来源:DomainServices.cs

示例3: TestDistributionListAnnouncementFromDomainAlias

        public void TestDistributionListAnnouncementFromDomainAlias()
        {
            var smtpClientSimulator = new SmtpClientSimulator();

             //
             // TEST LIST SECURITY IN COMBINATION WITH DOMAIN NAME ALIASES
             //

             Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             var oRecipients = new List<string>();
             oRecipients.Add("[email protected]");

             DistributionList oList3 = SingletonProvider<TestSetup>.Instance.AddDistributionList(_domain, "[email protected]",
                                                                                             oRecipients);
             oList3.Mode = eDistributionListMode.eLMAnnouncement;
             oList3.RequireSenderAddress = "[email protected]";
             oList3.Save();

             // THIS MESSAGE SHOULD FAIL
             CustomAsserts.Throws<DeliveryFailedException>(()=> smtpClientSimulator.Send("[email protected]", "[email protected]", "Mail 1", "Mail 1"));

             DomainAlias oDA = _domain.DomainAliases.Add();
             oDA.AliasName = "dummy-example.com";
             oDA.Save();

             // THIS MESSAGE SHOULD SUCCEED
             smtpClientSimulator.Send("[email protected]", "[email protected]", "Mail 1", "Mail 1");
             ImapClientSimulator.AssertMessageCount("[email protected]", "test", "Inbox", 1);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:30,代码来源:DistributionLists.cs

示例4: RequestingSameHeaderFieldMultipleTimesShouldReturnItOnce

        public void RequestingSameHeaderFieldMultipleTimesShouldReturnItOnce()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             string message = "From: Someone <[email protected]>" + Environment.NewLine +
                          "To: Someoen <[email protected]>" + Environment.NewLine +
                          "Date: Wed, 22 Apr 2009 11:05:09 \"GMT\"" + Environment.NewLine +
                          "Subject: SubjectText" + Environment.NewLine +
                          Environment.NewLine +
                          "Hello" + Environment.NewLine;

             var smtpSimulator = new SmtpClientSimulator();
             smtpSimulator.SendRaw(account.Address, account.Address, message);

             Pop3ClientSimulator.AssertMessageCount(account.Address, "test", 1);

             var oSimulator = new ImapClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(account.Address, "test");
             oSimulator.SelectFolder("INBOX");
             string result = oSimulator.Fetch("1 BODY.PEEK[HEADER.FIELDS (Subject Subject)]");
             oSimulator.Disconnect();

             Assert.AreEqual(1, StringExtensions.Occurences(result, "SubjectText"));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:25,代码来源:Fetch.cs

示例5: IfInReplyToFieldContainsQuoteThenFetchHeadersShouldEncodeIt

        public void IfInReplyToFieldContainsQuoteThenFetchHeadersShouldEncodeIt()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             string message = "From: Someone <[email protected]>" + Environment.NewLine +
                          "To: Someoen <[email protected]>" + Environment.NewLine +
                          "In-Reply-To: ShouldBeEncodedDueToQuote\"" + Environment.NewLine +
                          "Subject: Something" + Environment.NewLine +
                          Environment.NewLine +
                          "Hello" + Environment.NewLine;

             var smtpSimulator = new SmtpClientSimulator();
             smtpSimulator.SendRaw(account.Address, account.Address, message);

             Pop3ClientSimulator.AssertMessageCount(account.Address, "test", 1);

             var oSimulator = new ImapClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(account.Address, "test");
             oSimulator.SelectFolder("INBOX");
             string result = oSimulator.Fetch("1 ENVELOPE");
             oSimulator.Disconnect();

             Assert.IsFalse(result.Contains("ShouldBeEncodedDueToQuote"));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:25,代码来源:Fetch.cs

示例6: TestBlockingDeliveries

        public void TestBlockingDeliveries()
        {
            SecurityRange range =
            SingletonProvider<TestSetup>.Instance.GetApp().Settings.SecurityRanges.get_ItemByName("My computer");
             range.RequireSMTPAuthLocalToLocal = false;
             range.RequireSMTPAuthLocalToExternal = false;
             range.RequireSMTPAuthExternalToLocal = false;
             range.RequireSMTPAuthExternalToExternal = false;

             range.AllowDeliveryFromLocalToLocal = false;
             range.AllowDeliveryFromLocalToRemote = false;
             range.AllowDeliveryFromRemoteToLocal = false;
             range.AllowDeliveryFromRemoteToRemote = false;

             range.Save();

             Account account1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             var smtpClientSimulator = new SmtpClientSimulator();

             string result1 = "", result2 = "", result3 = "", result4 = "";

             CustomAsserts.Throws<DeliveryFailedException>(() => smtpClientSimulator.Send(account1.Address, account1.Address, "Mail 1", "Mail 1", out result1));
             CustomAsserts.Throws<DeliveryFailedException>(() => smtpClientSimulator.Send(account1.Address, "[email protected]", "Mail 1", "Mail 1", out result2));
             CustomAsserts.Throws<DeliveryFailedException>(() => smtpClientSimulator.Send("[email protected]", account1.Address, "Mail 1", "Mail 1", out result3));
             CustomAsserts.Throws<DeliveryFailedException>(() => smtpClientSimulator.Send("[email protected]", "[email protected]", "Mail 1", "Mail 1",
                                   out result4));

             Assert.IsTrue(result1.Contains("550 Delivery is not allowed to this address."));
             Assert.IsTrue(result2.Contains("550 Delivery is not allowed to this address."));
             Assert.IsTrue(result3.Contains("550 Delivery is not allowed to this address."));
             Assert.IsTrue(result4.Contains("550 Delivery is not allowed to this address."));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:33,代码来源:SMTPAuthentication.cs

示例7: ConfirmSingleReturnPathAfterAccountForward

        public void ConfirmSingleReturnPathAfterAccountForward()
        {
            // Create a test account
             // Fetch the default domain
             Account oAccount1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
             Account oAccount2 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             oAccount1.ForwardAddress = oAccount2.Address;
             oAccount1.ForwardEnabled = true;
             oAccount1.Save();

             // Send a message...
             var smtpClientSimulator = new SmtpClientSimulator();
             smtpClientSimulator.Send("[email protected]", oAccount1.Address, "Test message", "This is the body");

             CustomAsserts.AssertRecipientsInDeliveryQueue(0);
             _application.SubmitEMail();

             // Wait for the auto-reply.
             string text = Pop3ClientSimulator.AssertGetFirstMessageText(oAccount2.Address, "test");

             Assert.IsFalse(text.Contains("Return-Path: [email protected]"));
             Assert.IsFalse(text.Contains("Return-Path: [email protected]"));
             Assert.IsTrue(text.Contains("Return-Path: [email protected]"));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:25,代码来源:AccountServices.cs

示例8: SmtpServerNOTSupportingStartTls_StartTlsRequired

        public void SmtpServerNOTSupportingStartTls_StartTlsRequired()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             // Set up a server listening on port 250 which accepts email for [email protected]
             var deliveryResults = new Dictionary<string, int>();
             deliveryResults["[email protected]"] = 250;

             int smtpServerPort = TestSetup.GetNextFreePort();
             using (var server = new SmtpServerSimulator(1, smtpServerPort, eConnectionSecurity.eCSNone))
             {
            server.SetCertificate(SslSetup.GetCertificate());
            server.AddRecipientResult(deliveryResults);
            server.StartListen();

            Route route = TestSetup.AddRoutePointingAtLocalhost(1, smtpServerPort, true, eConnectionSecurity.eCSSTARTTLSRequired);

            var smtpClient = new SmtpClientSimulator();
            smtpClient.Send(account.Address, "[email protected]", "Test", "Test message");

            CustomAsserts.AssertRecipientsInDeliveryQueue(0);

            // This should now be processed via the rule -> route -> external server we've set up.
            server.WaitForCompletion();

            var msg = Pop3ClientSimulator.AssertGetFirstMessageText("[email protected]", "test");

            Assert.IsTrue(msg.Contains("Server does not support STARTTLS"));
             }
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:30,代码来源:SmtpDeliverySslTests.cs

示例9: TestNestedOrSearch

        public void TestNestedOrSearch()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             // Send a message to this account.
             var smtpClientSimulator = new SmtpClientSimulator();
             smtpClientSimulator.Send("[email protected]", "[email protected]", "Search test", "This is a test of IMAP Search");

             ImapClientSimulator.AssertMessageCount(oAccount.Address, "test", "Inbox", 1);

             var oSimulator = new ImapClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("[email protected]", "test");
             oSimulator.SelectFolder("INBOX");

             string result =
            oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SINCE 28-May-2008 SINCE 28-May-2008 SINCE 28-May-2008");
             Assert.IsTrue(result.StartsWith("* SEARCH 1"), result);

             result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR SMALLER 1 LARGER 10000");
             Assert.IsTrue(result.StartsWith("* SEARCH\r\n"), result);

             result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SMALLER 1 LARGER 10000 SMALLER 10000");
             Assert.IsTrue(result.StartsWith("* SEARCH 1\r\n"), result);
        }
开发者ID:hmailserver,项目名称:hmailserver,代码行数:27,代码来源:Search.cs

示例10: DoNotUseStartTlsIfNotEnabledAndNotAvailable

        public void DoNotUseStartTlsIfNotEnabledAndNotAvailable()
        {
            // No valid recipients...
             var deliveryResults = new Dictionary<string, int>();
             deliveryResults["[email protected]"] = 250;

             int smtpServerPort = TestSetup.GetNextFreePort();
             using (var server = new SmtpServerSimulator(1, smtpServerPort, eConnectionSecurity.eCSNone))
             {
            server.AddRecipientResult(deliveryResults);
            server.StartListen();

            Route route = TestSetup.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone);

            // Send message to this route.
            var smtp = new SmtpClientSimulator();
            smtp.Send("[email protected]", "[email protected]", "Test", "Test message");

            // Wait for the client to disconnect.
            server.WaitForCompletion();

            CustomAsserts.AssertRecipientsInDeliveryQueue(0, false);

            Assert.IsNotNullOrEmpty(server.MessageData);

            Assert.IsFalse(LogHandler.DefaultLogContains("220 Ready to start TLS"));
             }
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:28,代码来源:SMTPClientStartTLSTests.cs

示例11: StaticSend

        public static void StaticSend(string sFrom, string recipient, string sSubject, string sBody)
        {
            var messageRecipients = new List<string>();
             messageRecipients.Add(recipient);

             var oSimulator = new SmtpClientSimulator();
             oSimulator.Send(sFrom, messageRecipients, sSubject, sBody);
        }
开发者ID:hmailserver,项目名称:hmailserver,代码行数:8,代码来源:SMTPClientSimulator.cs

示例12: TestCaseInsensitivtyAccount

        public void TestCaseInsensitivtyAccount()
        {
            Account testAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             var smtpClientSimulator = new SmtpClientSimulator();
             string upperCase = testAccount.Address.ToUpper();
             smtpClientSimulator.Send("[email protected]", upperCase, "test mail", "test body");

             Pop3ClientSimulator.AssertMessageCount("[email protected]", "test", 1);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:10,代码来源:Basics.cs

示例13: TestESMTPAInHeader

        public void TestESMTPAInHeader()
        {
            string errorMessage;

             var client = new SmtpClientSimulator();
             client.Send(false, _account.Address, "test", _account.Address, _account.Address, "Test", "Test", out errorMessage);

             var message = Pop3ClientSimulator.AssertGetFirstMessageText(_account.Address, "test");

             Assert.IsTrue(message.Contains("ESMTPA\r\n"));
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:11,代码来源:ReceivedHeaders.cs

示例14: ItShouldBePossibleToEnableSslV3

        public void ItShouldBePossibleToEnableSslV3()
        {
            SetSslVersions(true, false, false, false);
             var smtpClientSimulator = new SmtpClientSimulator(true, SslProtocols.Ssl3, 25001, IPAddress.Parse("127.0.0.1"));

             string errorMessage;
             smtpClientSimulator.Send(false, _account.Address, "test", _account.Address, _account.Address, "Test", "test", out errorMessage);

             var message = Pop3ClientSimulator.AssertGetFirstMessageText(_account.Address, "test");
             Assert.IsTrue(message.Contains("version=SSLv3"), message);
        }
开发者ID:hmailserver,项目名称:hmailserver,代码行数:11,代码来源:SslTlsVersionTests.cs

示例15: WhenSSL3IsDisabledTLSShouldWork

        public void WhenSSL3IsDisabledTLSShouldWork()
        {
            SetSslVersions(false, true, true, true);
             var smtpClientSimulator = new SmtpClientSimulator(true, SslProtocols.Tls, 25001, IPAddress.Parse("127.0.0.1"));

             string errorMessage;
             smtpClientSimulator.Send(false, _account.Address, "test", _account.Address, _account.Address, "Test", "test", out errorMessage);

             var message = Pop3ClientSimulator.AssertGetFirstMessageText(_account.Address, "test");
             Assert.IsTrue(message.Contains("version=TLSv1"), message);
        }
开发者ID:hmailserver,项目名称:hmailserver,代码行数:11,代码来源:SslTlsVersionTests.cs


注:本文中的RegressionTests.Shared.SmtpClientSimulator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。