Exemplo n.º 1
0
        public void TestChangeRecentFlag()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Assert.IsTrue(SMTPClientSimulator.StaticSend("*****@*****.**", oAccount.Address, "Test", "test"));
            POP3Simulator.AssertMessageCount(oAccount.Address, "test", 1);

            IMAPSimulator simulator = new IMAPSimulator();

            simulator.ConnectAndLogon(oAccount.Address, "test");
            string result = simulator.ExamineFolder("Inbox");

            Assert.IsTrue(result.Contains("* 1 RECENT"), result);
            simulator.Close();
            simulator.Disconnect();

            simulator = new IMAPSimulator();
            simulator.ConnectAndLogon(oAccount.Address, "test");
            Assert.IsTrue(simulator.SelectFolder("Inbox", out result));
            Assert.IsTrue(result.Contains("* 1 RECENT"), result);
            simulator.Close();
            simulator.Disconnect();

            simulator = new IMAPSimulator();
            simulator.ConnectAndLogon(oAccount.Address, "test");
            result = simulator.ExamineFolder("Inbox");
            Assert.IsTrue(result.Contains("* 0 RECENT"), result);
            simulator.Close();
            simulator.Disconnect();
        }
Exemplo n.º 2
0
        public void TestExpunge()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Assert.IsTrue(SMTPClientSimulator.StaticSend("*****@*****.**", oAccount.Address, "Test", "test"));
            POP3Simulator.AssertMessageCount(oAccount.Address, "test", 1);

            IMAPSimulator simulator = new IMAPSimulator();

            simulator.ConnectAndLogon(oAccount.Address, "test");
            simulator.SelectFolder("Inbox");
            Assert.IsTrue(simulator.SetFlagOnMessage(1, true, @"\Deleted"));

            IMAPSimulator secondSimulator = new IMAPSimulator();

            secondSimulator.ConnectAndLogon(oAccount.Address, "test");
            string result = secondSimulator.ExamineFolder("INBOX");

            Assert.IsTrue(result.Contains("1 EXISTS"), result);
            Assert.IsFalse(secondSimulator.Expunge());

            simulator.SelectFolder("INBOX");
            Assert.IsTrue(simulator.Expunge());

            simulator.Close();
            secondSimulator.Close();
        }
Exemplo n.º 3
0
        public void TestChangeSeenFlag()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Assert.IsTrue(SMTPClientSimulator.StaticSend("*****@*****.**", oAccount.Address, "Test", "test"));
            POP3Simulator.AssertMessageCount(oAccount.Address, "test", 1);

            IMAPSimulator simulator = new IMAPSimulator();

            simulator.ConnectAndLogon(oAccount.Address, "test");
            simulator.ExamineFolder("Inbox");
            string flags      = simulator.GetFlags(1);
            string body       = simulator.Fetch("1 RFC822");
            string flagsAfter = simulator.GetFlags(1);

            simulator.Close();
            simulator.Disconnect();

            Assert.AreEqual(flags, flagsAfter);

            IMAPSimulator secondSimulator = new IMAPSimulator();

            secondSimulator.ConnectAndLogon(oAccount.Address, "test");
            secondSimulator.SelectFolder("Inbox");
            string secondFlags      = secondSimulator.GetFlags(1);
            string secondBody       = secondSimulator.Fetch("1 RFC822");
            string secondFlagsAfter = secondSimulator.GetFlags(1);

            secondSimulator.Close();
            secondSimulator.Disconnect();

            Assert.AreNotEqual(secondFlags, secondFlagsAfter);
        }
Exemplo n.º 4
0
        public void TestDelete()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             Assert.IsFalse(oSimulator.DeleteFolder("DoesNotExist"));
             Assert.IsTrue(oSimulator.CreateFolder("DoesExist"));
             Assert.IsTrue(oSimulator.SelectFolder("DoesExist"));
             oSimulator.Close();
             Assert.IsTrue(oSimulator.DeleteFolder("DoesExist"));
             Assert.IsFalse(oSimulator.SelectFolder("DoesExist"));
        }
Exemplo n.º 5
0
        public void TestUnseenResponseInSelect()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestMessage");

             IMAPSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);

             IMAPSimulator sim = new IMAPSimulator();
             Assert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
             Assert.IsTrue(sim.SelectFolder("Inbox"));
             Assert.IsTrue(sim.CreateFolder("Dummy"));
             Assert.IsTrue(sim.Copy(1, "Dummy"));

             string result = sim.SendSingleCommand("a01 select Dummy");
             Assert.IsTrue(result.Contains("* 1 EXISTS\r\n* 1 RECENT"), result);

             string searchResponse = sim.SendSingleCommand("srch1 SEARCH ALL UNSEEN");

             // We should have at least one message here.
             Assert.IsTrue(searchResponse.Contains("* SEARCH 1\r\n"), searchResponse);

             // Now fetch the body.
             string bodyText = sim.Fetch("1 BODY[TEXT]");

             // Now the message is no longer unseen. Confirm this.
             searchResponse = sim.SendSingleCommand("srch1 SEARCH ALL UNSEEN");
             Assert.IsTrue(searchResponse.Contains("* SEARCH\r\n"), searchResponse);

             // Close the messages to mark them as no longer recent.
             Assert.IsTrue(sim.Close());

             result = sim.SendSingleCommand("a01 select Dummy");
             Assert.IsTrue(result.Contains("* 1 EXISTS\r\n* 0 RECENT"), result);
        }