public void TestAllEmails() { foreach (string fpath in Directory.GetFiles("OrderRequests", "*.txt")) { Console.WriteLine(fpath); MailMessage msg = new MailMessage { Subject = "Order Request", Body = File.ReadAllText(fpath) }; OrderRequest orderReq = OrderRequest.FromEmail(msg); Assert.IsFalse(string.IsNullOrEmpty(orderReq.CustomerName)); Assert.IsFalse(string.IsNullOrEmpty(orderReq.SalesRepName)); Assert.IsNotNull(orderReq.OrderDate); Assert.IsNotNull(orderReq.RequiredDate); Assert.IsFalse(string.IsNullOrEmpty(orderReq.ShipperName));; Assert.IsTrue(orderReq.Freight > 0); Assert.IsTrue(orderReq.ProductDetails.All(p => !string.IsNullOrEmpty(p.ProductName))); Assert.IsTrue(orderReq.ProductDetails.All(p => p.Discount >= 0)); Assert.IsTrue(orderReq.ProductDetails.All(p => p.Quantity > 0)); } }
public void FromEmail() { string emailBody = File.ReadAllText("OrderRequests\\Order Request-Antonio Moreno Taquería.txt"); MailMessage email = new MailMessage { Subject = "Order Request", Body = emailBody }; OrderRequest orderReq = OrderRequest.FromEmail(email); DateTime date = new DateTime(2018, 12, 04); DateTime dateII = new DateTime(2018, 12, 11); DateTime dateIII = DateTime.Now.Date.AddDays(7); Assert.AreEqual("Antonio Moreno Taquería", orderReq.CustomerName); Assert.AreEqual("Michael Suyama", orderReq.SalesRepName); Assert.AreEqual(6, orderReq.SalesRepID); Assert.AreEqual(date, orderReq.OrderDate); Assert.AreEqual(dateII, orderReq.RequiredDate); Assert.AreEqual(1, orderReq.ShipperID); Assert.AreEqual(1554.98m, orderReq.Freight); Assert.AreEqual("Speedy Express", orderReq.ShipperName); Assert.AreEqual(8, orderReq.ProductDetails.Count); ProductDetail product = orderReq.ProductDetails.Last(); Assert.AreEqual("Röd Kaviar", product.ProductName); Assert.AreEqual(73M, product.ProductID); Assert.AreEqual(30M, product.Quantity); Assert.AreEqual(0.03M, product.Discount); }
public void TestAllEmail() { foreach (string fpath in Directory.GetFiles("OrderRequests", "*.txt")) { MailMessage msg = new MailMessage { Subject = "Order Request", Body = File.ReadAllText(fpath) }; Console.WriteLine(fpath); OrderRequest notice = OrderRequest.FromEmail(msg); Assert.IsFalse(string.IsNullOrEmpty(notice.Company)); Assert.IsFalse(string.IsNullOrEmpty(notice.PlacedBy)); Assert.IsFalse(string.IsNullOrEmpty(notice.Shipper)); Assert.IsTrue(notice.Freight > 0); Assert.IsNotNull(notice.OrderDetails); Assert.IsTrue(notice.OrderDetails.Count >= 1); OrderRequestDetails details = notice.OrderDetails.Last(); Assert.IsTrue(details.Quantity > 0); Assert.IsFalse(string.IsNullOrEmpty(details.Product)); Assert.IsFalse(string.IsNullOrEmpty(details.ProductID)); Assert.IsTrue(details.Discount >= 0); //Can't be null: Company, PlacedBy, Shipper, Product, ProductID //Is true: Shipping = Default //Greater than "0" = Freight, Quantity //Greater than or Equal to "0" = Discount //OrderDetails: Product, ProductID, Quantity, Discount } }
public void FromEmail() { string emailBody = File.ReadAllText("OrderRequests\\Order Request-Antonio Moreno Taquería.txt"); MailMessage email = new MailMessage { Subject = "Order Request", Body = emailBody }; OrderRequest request = OrderRequest.FromEmail(email); DateTime date = new DateTime(2018, 12, 04); DateTime date2 = new DateTime(2018, 12, 11); DateTime date3 = DateTime.Today.AddDays(7); Assert.AreEqual("Antonio Moreno Taquería (ANTON)", request.Customer); Assert.AreEqual("Michael Suyama (6)", request.SalesRep); Assert.AreEqual(date, request.OrderDate); Assert.AreEqual(date2, request.RequiredDate); Assert.AreEqual("Speedy Express (1)", request.Shipper); Assert.AreEqual(1554.98m, request.Freight); Assert.AreEqual(date3, request.ShipDate); Assert.AreEqual(8, request.ProductDetails.Count); ProductDetail product = request.ProductDetails.Last(); Assert.AreEqual("Röd Kaviar", product.ProductName); Assert.AreEqual(73m, product.ProductID); Assert.AreEqual(30m, product.Quantity); Assert.AreEqual(0.03m, product.Discount); }
public void FromEmail() { string emailBody = File.ReadAllText("OrderRequests\\Order Request-Princesa Isabel Vinhos.txt"); MailMessage email = new MailMessage { Subject = "Order Request", Body = emailBody }; //Company, PlacedBy, OrderDate, RequiredDate, Shipper, Freight, Shipping OrderRequest notice = OrderRequest.FromEmail(email); Assert.AreEqual("Princesa Isabel Vinhos (PRINI)", notice.Company); Assert.AreEqual("Andrew Fuller (2)", notice.PlacedBy); Assert.AreEqual(12 - 04 - 2018, notice.OrderDate); Assert.AreEqual(12 - 11 - 2018, notice.RequiredDate); Assert.AreEqual("United Package (2)", notice.Shipper); Assert.AreEqual(179.72M, notice.Freight); Assert.AreEqual("default", notice.Shipping); //Prdouct, ProductID, Quantity, Discount OrderRequestDetails detail = notice.OrderDetails.Last(); Assert.AreEqual("Teatime Chocolate Biscuits", detail.Product); Assert.AreEqual("(19)", detail.ProductID); Assert.AreEqual(5M, detail.Quantity); Assert.AreEqual(0M, detail.Discount); }