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


C# ImapPseudoServer.DequeueAll方法代码示例

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


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

示例1: TestBeginGetRequestStreamCallback

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

            // 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");
            // APPEND
            server.EnqueueResponse("+ continue\r\n");
            server.EnqueueResponse(string.Empty);

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

            request.Method = "APPEND";
            request.Timeout = 3000;
            request.ReadWriteTimeout = 3000;
            request.AllowInsecureLogin = true;

            var asyncResult = request.BeginGetRequestStream((AsyncCallback)BeginGetRequestStreamCallbackProc, request);

            Thread.Sleep(100); // XXX

            if (!asyncResult.AsyncWaitHandle.WaitOne(5000))
              Assert.Fail("wait time out");

            server.EnqueueResponse("0002 OK done\r\n");

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

            server.DequeueRequest(); // CAPABILITY
            server.DequeueRequest(); // LOGIN

            var appendCommand = server.DequeueAll();

            StringAssert.StartsWith("0002 APPEND \"INBOX\" ", appendCommand);
            StringAssert.EndsWith(" {12}\r\ntest message\r\n", appendCommand);
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:45,代码来源:ImapMailboxWebRequest.cs

示例2: TestGetRequestStreamWriteOverContentLength

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

            // 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");
            // APPEND
            server.EnqueueResponse("+ continue\r\n");
            server.EnqueueResponse(string.Empty);

            var message = "test message";
            var data = Encoding.ASCII.GetBytes(message);
            var request = WebRequest.Create(string.Format("imap://{0}/INBOX", server.HostPort)) as ImapWebRequest;

            request.Method = "APPEND";
            request.Timeout = 3000;
            request.ReadWriteTimeout = 3000;
            request.ContentLength = data.Length;
            request.AllowInsecureLogin = true;

            using (var stream = request.GetRequestStream()) {
              stream.Write(data, 0, data.Length);

              // extra data
              stream.WriteByte(0x40);
              stream.WriteByte(0x40);
              stream.WriteByte(0x40);
              stream.WriteByte(0x40);
            }

            server.EnqueueResponse("0002 OK done\r\n");

            using (var response = request.GetResponse() as ImapWebResponse) {
              Assert.IsNotNull(response.GetResponseStream());

              Assert.IsNotNull(response.Result);
              Assert.IsTrue(response.Result.Succeeded);
            }

            server.DequeueRequest(); // CAPABILITY
            server.DequeueRequest(); // LOGIN

            var appendCommand = server.DequeueAll();

            StringAssert.StartsWith("0002 APPEND \"INBOX\" ", appendCommand);
            StringAssert.EndsWith(string.Format(" {{{0}}}\r\n{1}\r\n", Encoding.ASCII.GetByteCount(message), message), appendCommand);
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:55,代码来源:ImapMailboxWebRequest.cs

示例3: GetAppendResponse

        private void GetAppendResponse(bool appendUid)
        {
            using (var server = new ImapPseudoServer()) {
            server.Start();

            // 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");
            // APPEND
            server.EnqueueResponse("+ continue\r\n");
            server.EnqueueResponse(string.Empty);

            var message = "test message";
            var data = Encoding.ASCII.GetBytes(message);
            var request = WebRequest.Create(string.Format("imap://{0}/INBOX", server.HostPort)) as ImapWebRequest;

            request.Method = "APPEND";
            request.Timeout = 3000;
            request.ReadWriteTimeout = 3000;
            request.ContentLength = data.Length;
            request.AllowInsecureLogin = true;

            using (var stream = request.GetRequestStream()) {
              stream.Write(data, 0, data.Length);
            }

            if (appendUid)
              server.EnqueueResponse("0002 OK [APPENDUID 38505 3955] done\r\n");
            else
              server.EnqueueResponse("0002 OK done\r\n");

            using (var response = request.GetResponse() as ImapWebResponse) {
              Assert.IsNotNull(response.GetResponseStream());

              if (appendUid)
            Assert.AreEqual(new Uri(string.Format("imap://{0}/INBOX;UIDVALIDITY=38505/;UID=3955", server.HostPort)), response.ResponseUri);
              else
            Assert.AreEqual(request.RequestUri, response.ResponseUri);

              Assert.IsNotNull(response.Result);
              Assert.IsTrue(response.Result.Succeeded);
            }

            server.DequeueRequest(); // CAPABILITY
            server.DequeueRequest(); // LOGIN

            var appendCommand = server.DequeueAll();

            StringAssert.StartsWith("0002 APPEND \"INBOX\" ", appendCommand);
            StringAssert.EndsWith(string.Format(" {{{0}}}\r\n{1}\r\n", Encoding.ASCII.GetByteCount(message), message), appendCommand);
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:57,代码来源:ImapMailboxWebRequest.cs

示例4: TestGetAppendResponseFailure

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

            // 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");
            // APPEND
            server.EnqueueResponse("0002 NO failed\r\n");

            var message = "test message";
            var data = Encoding.ASCII.GetBytes(message);
            var request = WebRequest.Create(string.Format("imap://{0}/INBOX", server.HostPort)) as ImapWebRequest;

            request.Method = "APPEND";
            request.Timeout = 3000;
            request.ReadWriteTimeout = 3000;
            request.AllowInsecureLogin = true;

            using (var stream = request.GetRequestStream()) {
              stream.Write(data, 0, data.Length);
            }

            try {
              using (var response = request.GetResponse()) {
              }
            }
            catch (WebException ex) {
              Assert.AreEqual(WebExceptionStatus.ProtocolError, ex.Status);

              var resp = ex.Response as ImapWebResponse;

              Assert.IsNotNull(resp);

              Assert.AreEqual(request.RequestUri, resp.ResponseUri);
              Assert.IsNotNull(resp.Result);
              Assert.IsTrue(resp.Result.Failed);
            }

            server.DequeueRequest(); // CAPABILITY
            server.DequeueRequest(); // LOGIN

            var appendCommand = server.DequeueAll();

            StringAssert.StartsWith("0002 APPEND \"INBOX\" ", appendCommand);
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:53,代码来源:ImapMailboxWebRequest.cs

示例5: AssertAppendRequest

        private void AssertAppendRequest(ImapPseudoServer server)
        {
            server.DequeueRequest(); // LOGIN

              var appendRequest = server.DequeueRequest();

              StringAssert.StartsWith("0001 APPEND \"INBOX\"", appendRequest);
              StringAssert.EndsWith(string.Format(" {{{0}}}\r\n", Encoding.ASCII.GetByteCount(message)), appendRequest);

              StringAssert.StartsWith(message, server.DequeueAll());
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:11,代码来源:WebClient.cs


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