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


C# ImapPseudoServer.Stop方法代码示例

本文整理汇总了C#中ImapPseudoServer.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# ImapPseudoServer.Stop方法的具体用法?C# ImapPseudoServer.Stop怎么用?C# ImapPseudoServer.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImapPseudoServer的用法示例。


在下文中一共展示了ImapPseudoServer.Stop方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestCreateSessionConnectFailure

        public void TestCreateSessionConnectFailure()
        {
            using (var server = new ImapPseudoServer()) {
            server.Start();

            var credential = new NetworkCredential("user", "pass");
            var request = WebRequest.Create(string.Format("imap://{0}@{1}/", credential.UserName, server.HostPort)) as ImapWebRequest;

            request.Timeout = 500;

            server.Stop();

            try {
              using (var response = request.GetResponse()) {
              }
            }
            catch (WebException ex) {
              WebExceptionAssertion(WebExceptionStatus.ConnectFailure, ex);
            }
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:21,代码来源:ImapSessionManager.cs

示例2: TestGetResponseKeepAliveFalse

        public void TestGetResponseKeepAliveFalse()
        {
            using (var server = new ImapPseudoServer()) {
            for (var req = 0; req < 3; req++) {
              server.Start();

              /*
               * request/response
               */
              var request = WebRequest.Create(string.Format("imap://{0}/", server.HostPort)) as ImapWebRequest;

              request.Timeout = 1000;
              request.Method = "NOOP";
              request.KeepAlive = false;

              // greeting
              server.EnqueueResponse("* OK ready\r\n");
              // CAPABILITY
              server.EnqueueResponse("* CAPABILITY IMAP4rev1\r\n" +
                                 "0000 OK done\r\n");
              // LOGIN
              server.EnqueueResponse("* CAPABILITY IMAP4rev1\r\n" +
                                 "0001 OK done\r\n");
              // NOOP
              server.EnqueueResponse("0002 OK done\r\n");
              // LOGOUT
              server.EnqueueResponse("* BYE logging out\r\n" +
                                 "0003 OK done\r\n");

              using (var response = request.GetResponse()) {
              }

              server.DequeueRequest(); // CAPABILITY
              server.DequeueRequest(); // LOGIN
              StringAssert.Contains("NOOP", server.DequeueRequest(), "request #{0}", req);
              StringAssert.Contains("LOGOUT", server.DequeueRequest(), "request #{0}", req);

              server.Stop();
            }
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:41,代码来源:ImapWebRequest.cs

示例3: TestExceptionWhileCloseSession

        private void TestExceptionWhileCloseSession(string test)
        {
            using (var server = new ImapPseudoServer()) {
            server.Start();

            var request = WebRequest.Create(string.Format("imap://{0}/", server.HostPort)) as ImapWebRequest;

            request.Timeout = 3000;
            request.ReadWriteTimeout = 3000;

            request.Method = ImapWebRequestMethods.NoOp;
            request.KeepAlive = false;

            // greeting
            server.EnqueueResponse("* OK ready\r\n");
            // CAPABILITY
            server.EnqueueResponse("* CAPABILITY IMAP4rev1\r\n" +
                               "0000 OK done\r\n");
            // LOGIN
            server.EnqueueResponse("* CAPABILITY IMAP4rev1\r\n" +
                               "0001 OK done\r\n");
            // NOOP
            server.EnqueueResponse("0002 OK done\r\n");

            var asyncResult = request.BeginGetResponse(null, null);

            Thread.Sleep(500);

            server.DequeueRequest(); // CAPABILITY
            server.DequeueRequest(); // LOGIN
            StringAssert.Contains("NOOP", server.DequeueRequest());

            if (test == "not responding")
              // not respond to LOGOUT
              ;
            else if (test == "disconnected")
              server.Stop();

            using (var response = request.EndGetResponse(asyncResult) as ImapWebResponse) {
              Assert.IsTrue(response.Result.Succeeded);
            }
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:43,代码来源:ImapWebRequest.cs

示例4: KeepAliveAndDisconnected

        private void KeepAliveAndDisconnected(bool disconnectFromServer)
        {
            using (var server = new ImapPseudoServer()) {
            for (var req = 0; req < 2; req++) {
              server.Start();

              /*
               * request/response
               */
              var request = WebRequest.Create(string.Format("imap://{0}/", server.HostPort)) as ImapWebRequest;

              request.Timeout = 1000;
              request.Method = "NOOP";
              request.KeepAlive = true;

              // greeting
              server.EnqueueResponse("* OK ready\r\n");
              // CAPABILITY
              server.EnqueueResponse("* CAPABILITY IMAP4rev1\r\n" +
                                 "0000 OK done\r\n");
              // LOGIN
              server.EnqueueResponse("* CAPABILITY IMAP4rev1\r\n" +
                                 "0001 OK done\r\n");
              // NOOP
              server.EnqueueResponse("0002 OK done\r\n");

              using (var response = request.GetResponse()) {
              }

              server.DequeueRequest(); // CAPABILITY
              server.DequeueRequest(); // LOGIN
              StringAssert.Contains("NOOP", server.DequeueRequest(), "request #{0}", req);

              if (disconnectFromServer) {
            server.Stop();
              }
              else {
            // LOGOUT
            server.EnqueueResponse("* BYE logging out\r\n" +
                                   "0003 OK done\r\n");

            ImapSessionManager.DisconnectFrom(request.RequestUri);

            server.DequeueRequest(); // LOGOUT

            server.Stop();
              }
            }
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:50,代码来源:ImapWebRequest.cs

示例5: TestCreateSessionCreateSslStreamCallbackNull

        public void TestCreateSessionCreateSslStreamCallbackNull()
        {
            using (var server = new ImapPseudoServer()) {
            server.Start();

            var prof = new Profile(new NetworkCredential("user", "pass"), "IMAPS", "user", server.HostPort);

            prof.Timeout = 500;

            server.Stop();

            ImapSessionCreator.CreateSession(prof, null, null);
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:14,代码来源:ImapSessionCreator.cs

示例6: TestCreateSessionConnectRefusedByTimeout

        public void TestCreateSessionConnectRefusedByTimeout()
        {
            using (var server = new ImapPseudoServer()) {
            server.Start();

            var prof = new Profile(new NetworkCredential("user", "pass"), "user", server.HostPort);

            prof.Timeout = 500;

            server.Stop();

            try {
              ImapSessionCreator.CreateSession(prof, null, null);

              Assert.Fail("ImapConnectionException not thrown");
            }
            catch (ImapConnectionException ex) {
              var timeoutException = ex.InnerException as TimeoutException;

              Assert.IsNotNull(timeoutException);
            }
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:23,代码来源:ImapSessionCreator.cs

示例7: TestGetRequestStreamGetSessionFailed

        public void TestGetRequestStreamGetSessionFailed()
        {
            string hostPort;

              using (var server = new ImapPseudoServer()) {
            server.Start();

            hostPort = server.HostPort;

            server.Stop();
              }

              var request = WebRequest.Create(string.Format("imap://{0}/INBOX", hostPort));

              request.Method = "APPEND";
              request.Timeout = 1000;

              try {
            request.GetRequestStream();
              }
              catch (WebException ex) {
            if (ex.Status != WebExceptionStatus.ConnectFailure)
              throw ex;
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:25,代码来源:ImapMailboxWebRequest.cs


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