public void Can_Create_The_Default_Order_Builder_With_Tasks() { //// Arrange const int taskCount = 1; var invoice = SalePreparationMock.PrepareInvoice(); PreTestDataWorker.InvoiceService.Save(invoice); //// Act var orderBuilder = new OrderBuilderChain(MockOrderStatusMaker.OrderStatusNotFulfilledMock(), invoice); //// Assert Assert.NotNull(orderBuilder); Assert.AreEqual(taskCount, orderBuilder.TaskCount); }
public void Can_Save_An_Order() { //// Arrange var invoice = SalePreparationMock.PrepareInvoice(); invoice.VersionKey = new Guid(); PreTestDataWorker.InvoiceService.Save(invoice); //// Act var orderBuilder = new OrderBuilderChain(MockOrderStatusMaker.OrderStatusNotFulfilledMock(), invoice); var attempt = orderBuilder.Build(); Assert.IsTrue(attempt.Success, "The order builder failed to create an order"); var order = attempt.Result; MerchelloContext.Current.Services.OrderService.Save(order); //// Assert Assert.IsTrue(order.HasIdentity); }
public void Can_Retrieve_An_Order() { //// Arrange var invoice = SalePreparationMock.PrepareInvoice(); invoice.VersionKey = new Guid(); PreTestDataWorker.InvoiceService.Save(invoice); var orderBuilder = new OrderBuilderChain(MockOrderStatusMaker.OrderStatusNotFulfilledMock(), invoice); var attempt = orderBuilder.Build(); Assert.IsTrue(attempt.Success, "The order builder failed to create an order"); MerchelloContext.Current.Services.OrderService.Save(attempt.Result); var key = attempt.Result.Key; //// Act var order = MerchelloContext.Current.Services.OrderService.GetByKey(key); //// Assert Assert.NotNull(order); Assert.AreEqual(key, order.Key); Assert.IsTrue(order.Items.Any()); }
public void Can_Transfer_InvoiceItems_To_OrderItems() { //// Arrange var invoice = SalePreparationMock.PrepareInvoice(); invoice.VersionKey = new Guid(); PreTestDataWorker.InvoiceService.Save(invoice); //// Act var orderBuilder = new OrderBuilderChain(MockOrderStatusMaker.OrderStatusNotFulfilledMock(), invoice); var attempt = orderBuilder.Build(); Assert.IsTrue(attempt.Success, "The order builder failed to create an order"); var order = attempt.Result; //// Assert Assert.IsTrue(order.Items.Any(), "The order does not contain any items"); foreach (var item in order.Items) { Console.WriteLine("Product: {0} - Quantity: {1}", item.Name, item.Quantity); } }