Skip to content

Commit fdbaa5a

Browse files
IMAP - Include manual Delete from Inbox Tests.
1 parent 06c1bba commit fdbaa5a

1 file changed

Lines changed: 58 additions & 7 deletions

File tree

Class Library/ActiveUp.Net.Tests/ImapTests.cs

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ImapTests
1616
private const string _imapPassword = "[password]";
1717
private const int _imapPort = 993;
1818
private const string _imapServerAddress = "imap.gmail.com";
19-
19+
2020

2121
[Test, Ignore("Manual tests")]
2222
public void dump_emails_for_tests()
@@ -27,7 +27,7 @@ public void dump_emails_for_tests()
2727
{
2828
foreach (var header in headers)
2929
writer.WriteLine(header);
30-
}
30+
}
3131
}
3232

3333
[Test, Ignore("Manual tests")]
@@ -58,7 +58,7 @@ public void download_imap_test()
5858

5959
Assert.IsTrue(true);
6060
}
61-
catch(Exception e)
61+
catch (Exception e)
6262
{
6363
Assert.Fail("Don't work.", e);
6464
}
@@ -75,21 +75,72 @@ public void download_imap_async_test()
7575
{
7676

7777
var result = _clientImap4.BeginConnectSsl(_imapServerAddress, _imapPort, callBack);
78-
79-
while(!result.CompletedSynchronously)
78+
79+
while (!result.CompletedSynchronously)
8080
{
8181
Console.WriteLine("Waiting execution....");
8282
}
8383
}
84-
84+
8585
Assert.IsTrue(true);
8686
}
8787
catch (Exception e)
8888
{
8989
Assert.Fail("Dont work.", e);
9090
}
9191
}
92-
92+
93+
[Test, Ignore("Manual tests")]
94+
public void delete_inbox_undeleted_messages_not_gmail()
95+
{
96+
var _selectedMailBox = "INBOX";
97+
using (var _clientImap4 = new Imap4Client())
98+
{
99+
_clientImap4.ConnectSsl(_imapServerAddress, _imapPort);
100+
_clientImap4.LoginFast(_imapLogin, _imapPassword);
101+
102+
var mails = _clientImap4.SelectMailbox(_selectedMailBox);
103+
var ids = mails.Search("UNDELETED");
104+
foreach (var id in ids)
105+
{
106+
mails.DeleteMessage(id, expunge: true);
107+
}
108+
109+
var mailsUndeleted = _clientImap4.SelectMailbox(_selectedMailBox);
110+
Assert.AreEqual(0, mailsUndeleted.Search("UNDELETED"));
111+
112+
_clientImap4.Disconnect();
113+
}
114+
}
115+
116+
[Test, Ignore("Manual tests")]
117+
public void delete_inbox_undeleted_messages_gmail()
118+
{
119+
var _selectedMailBox = "INBOX";
120+
using (var _clientImap4 = new Imap4Client())
121+
{
122+
_clientImap4.ConnectSsl(_imapServerAddress, _imapPort);
123+
_clientImap4.LoginFast(_imapLogin, _imapPassword);
124+
125+
// To see the names os all MailBox and found Trash
126+
_clientImap4.LoadMailboxes();
127+
var allMailBox = _clientImap4.AllMailboxes;
128+
129+
var mails = _clientImap4.SelectMailbox(_selectedMailBox);
130+
var ids = mails.Search("UNDELETED");
131+
foreach (var id in ids)
132+
{
133+
mails.DeleteMessage(id, expunge: false);
134+
mails.MoveMessage(id, "[Gmail]/Lixeira");
135+
}
136+
137+
var mailsUndeleted = _clientImap4.SelectMailbox(_selectedMailBox);
138+
Assert.AreEqual(0, mailsUndeleted.Search("UNDELETED"));
139+
140+
_clientImap4.Disconnect();
141+
}
142+
}
143+
93144
private void ImapAsyncCallBack(IAsyncResult result)
94145
{
95146
var resultStatus = result.AsyncState;

0 commit comments

Comments
 (0)