Esempio n. 1
0
        public void TestImapCommandException()
        {
            var expected = new ImapCommandException(ImapCommandResponse.Bad, "Bad boys, bad boys. Whatcha gonna do?", "Message", new Exception("InnerException"));

            using (var stream = new MemoryStream()) {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, expected);
                stream.Position = 0;

                var ex = (ImapCommandException)formatter.Deserialize(stream);
                Assert.AreEqual(expected.Response, ex.Response, "Unexpected Response.");
                Assert.AreEqual(expected.ResponseText, ex.ResponseText, "Unexpected ResponseText.");
            }

            expected = new ImapCommandException(ImapCommandResponse.Bad, "Bad boys, bad boys. Whatcha gonna do?", "Message");

            using (var stream = new MemoryStream()) {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, expected);
                stream.Position = 0;

                var ex = (ImapCommandException)formatter.Deserialize(stream);
                Assert.AreEqual(expected.Response, ex.Response, "Unexpected Response.");
                Assert.AreEqual(expected.ResponseText, ex.ResponseText, "Unexpected ResponseText.");
            }
        }
Esempio n. 2
0
        public void TestImapCommandException()
        {
            ImapCommandException expected;

            expected = new ImapCommandException(ImapCommandResponse.Ok, "This is the response text.");
            using (var stream = new MemoryStream()) {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, expected);
                stream.Position = 0;

                var ex = (ImapCommandException)formatter.Deserialize(stream);
                Assert.AreEqual(expected.Response, ex.Response, "Unexpected Response.");
                Assert.AreEqual(expected.ResponseText, ex.ResponseText, "Unexpected ResponseText.");
            }

            expected = new ImapCommandException(ImapCommandResponse.Ok, "This is the response text.", "This is the error message.");
            using (var stream = new MemoryStream()) {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, expected);
                stream.Position = 0;

                var ex = (ImapCommandException)formatter.Deserialize(stream);
                Assert.AreEqual(expected.Response, ex.Response, "Unexpected Response.");
                Assert.AreEqual(expected.ResponseText, ex.ResponseText, "Unexpected ResponseText.");
            }

            expected = new ImapCommandException(ImapCommandResponse.Ok, "This is the response text.", "This is the error message.", new IOException("This is the IO error."));
            using (var stream = new MemoryStream()) {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, expected);
                stream.Position = 0;

                var ex = (ImapCommandException)formatter.Deserialize(stream);
                Assert.AreEqual(expected.Response, ex.Response, "Unexpected Response.");
                Assert.AreEqual(expected.ResponseText, ex.ResponseText, "Unexpected ResponseText.");
            }
        }