public void TestParseMessageError2()
        {
            ServiceLocator.Current.Log = new MockLog();

            MockEmailHeader header = new MockEmailHeader(
                @"""Weston Thayer (SMS)"" <*****@*****.**>", // unknown email
                @"*****@*****.**",
                null,
                null,
                @"SMS from Weston Thayer [(444) 555-8888]"
                );

            MockEmail email = new MockEmail(header, null, "test");

            AssertExtensions.Throws(typeof(ArgumentException), () => GvEmailParser.ParseMessage(email));

            header = new MockEmailHeader(
                @"""Weston Thayer (SMS)"" <*****@*****.**>",
                @"", // can't be empty
                null,
                null,
                @"SMS from Weston Thayer [(444) 555-8888]"
                );

            email = new MockEmail(header, null, "test");

            AssertExtensions.Throws(typeof(ArgumentException), () => GvEmailParser.ParseMessage(email));

            header = new MockEmailHeader(
                @"Google Voice <*****@*****.**>",
                @"*****@*****.**",
                null,
                null,
                @"" // can't be empty, but only used with above From header
                );

            email = new MockEmail(header, null, "test");

            AssertExtensions.Throws(typeof(ArgumentException), () => GvEmailParser.ParseMessage(email));
        }
        public void TestParseMessageError1()
        {
            ServiceLocator.Current.Log = new MockLog();

            MockEmailHeader header = new MockEmailHeader(
                @"""Weston Thayer (SMS)"" <*****@*****.**>",
                @"*****@*****.**",
                null,
                null,
                @"SMS from Weston Thayer [(444) 555-8888]"
                );

            MockEmail email = new MockEmail(header, null, "test");

            Message result = GvEmailParser.ParseMessage(email);

            Assert.AreEqual("test", result.Body);
            Assert.AreEqual("+14445558888", result.Number);
            Assert.AreEqual("Weston Thayer", result.Sender);
            Assert.AreEqual(null, result.ThreadId);
            Assert.AreEqual("SMS", result.Type);
            Assert.AreEqual("*****@*****.**", result.UserEmail);
        }
Esempio n. 3
0
 public MockEmail(MockEmailHeader header, string data, string rawBody)
 {
     this.header = header;
     this.data = data;
     this.rawBody = rawBody;
 }