本文整理汇总了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);
}
}
}
示例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();
}
}
}
示例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);
}
}
}
示例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();
}
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
}