public void Can_Send_Email() { // Arrange - create and populate a cart Cart cart = new Cart(); cart.AddItem(new Product { ProductID = 1, Name = "Banana", Price = 10M }, 2); cart.AddItem(new Product { ProductID = 2, Name = "Apple", Price = 5M }, 2); // Arrange - create and populate some shipping details ShippingDetails shipDetails = new ShippingDetails { Name = "Joe Smith", Line1 = "Apartment 4a", Line2 = "123 West Street", City = "Northtown", State = "GA", Country = "USA", Zip = "12345" }; // Arrange - create the test-specific email settings EmailSettings settings = new EmailSettings { // put test specific settings here WriteAsFile = true }; // Arrange - create the EmailOrderProcessor class EmailOrderProcessor proc = new EmailOrderProcessor(settings); // Act - process the order proc.ProcessOrder(cart, shipDetails); // NOTE - there is assert in this test }
public ViewResult Checkout(Cart cart, ShippingDetails shippingDetails) { if (cart.Lines.Count() == 0) { ModelState.AddModelError("", "Sorry, your cart is empty!"); } if (ModelState.IsValid) { proc.ProcessOrder(cart, shippingDetails); cart.Clear(); return(View("Completed")); } else { return(View(shippingDetails)); } }
static void Main(string[] args) { var cart = new Cart(); cart.AddItem(new Product() { ProductID = 1, Name = "TEST1", Price = 10 }, 2); var persons = new ShippingDetails() { Name = "asdad", Address = "asdas", City = "asdas", GiftWrap = true }; foreach (var port in ports) { var mail = new EmailOrderProcessor(new EmailSettings(port)); try { Console.WriteLine("Запуск для порта " + port); mail.ProcessOrder(cart, persons); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Отправлено"); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); } Console.ResetColor(); Console.WriteLine("Завершено"); } Console.ReadLine(); }