public void FromEmail()
        {
            string      emailBody = File.ReadAllText("RestockNotices\\Shipment Received - Cooperativa de Quesos 'Las Cabras'.txt");
            MailMessage email     = new MailMessage
            {
                Subject = "Shipment Received",
                Body    = emailBody
            };

            RestockNotices notice  = RestockNotices.FromEmail(email);
            RestockDetails details = notice.RestockDetails.First();

            Assert.AreEqual(11, details.ProductID);
            Assert.AreEqual("Queso Cabrales", details.ProductName);
            Assert.AreEqual(30, details.Quantity);
        }
예제 #2
0
        public void FromEmail()
        {
            string      emailBody = File.ReadAllText("RestockNotices\\Restock Notice-Bigfoot Breweries.txt");
            MailMessage email     = new MailMessage
            {
                Subject = "Shipment Received",
                Body    = emailBody
            };
            RestockNotice  notice  = RestockNotice.FromEmail(email);
            RestockDetails details = notice.RestockDetails.First();

            Assert.AreEqual(35, details.ProductID);
            Assert.AreEqual("Steeleye Stout", details.ProductName);
            Assert.AreEqual(30, details.Quantity);
            Assert.AreEqual("Bigfoot Breweries (16)", notice.Supplier);
        }
 public void TestAllEmails()
 {
     foreach (string fpath in Directory.GetFiles("RestockNotices", "*.txt"))
     {
         MailMessage msg = new MailMessage
         {
             Subject = "Shipment Received",
             Body    = File.ReadAllText(fpath)
         };
         Console.WriteLine(fpath);
         RestockNotices notice  = RestockNotices.FromEmail(msg);
         RestockDetails details = notice.RestockDetails.First();
         Assert.IsTrue(details.Quantity > 0);
         Assert.IsTrue(details.ProductID > 0);
         Assert.IsFalse(string.IsNullOrEmpty(details.ProductName));
         Assert.IsNotNull(details.Quantity);
     }
 }
예제 #4
0
        public void FromEmail()
        {
            string      emailBody = File.ReadAllText("RestockNotices\\Shipment Received - Pavlova, Ltd..txt");
            MailMessage email     = new MailMessage
            {
                Subject = "Shipment Received",
                Body    = emailBody
            };
            //Supplier
            RestockNotice notice = RestockNotice.FromEmail(email);

            Assert.AreEqual("Pavlova, Ltd.", notice.Supplier);
            Assert.AreEqual("(7)", notice.SupplierID);

            //ProductID, ProductName, Quantity
            RestockDetails detail = notice.RestockDetails.Last();

            Assert.AreEqual(70, detail.ProductID);
            Assert.AreEqual("Outback Lager", detail.ProductName);
            Assert.AreEqual(10, detail.Quantity);
        }
예제 #5
0
        public void TestAllEmail()
        {
            foreach (string fpath in Directory.GetFiles("RestockNotices", "*.txt"))
            {
                MailMessage msg = new MailMessage
                {
                    Subject = "Shipment Received",
                    Body    = File.ReadAllText(fpath)
                };
                Console.WriteLine(fpath);
                RestockNotice notice = RestockNotice.FromEmail(msg);
                Assert.IsNotNull(notice.Supplier);
                Assert.IsNotNull(notice.SupplierID);

                RestockDetails details = notice.RestockDetails.Last();
                Assert.IsNotNull(details.ProductName);
                Assert.IsNotNull(details.ProductID);
                Assert.IsTrue(notice.Quantity > 0);

                //Can't be null: Supplier, SupplierID, ProductName
                //Greater than "0" = ProductID, Quantity
            }
        }