示例#1
0
        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);
        }
示例#2
0
        public void Can_Show_Dynamically_Bound_Event_Triggers()
        {
            //// Arrange
            var notFulfilled = MockOrderStatusMaker.OrderStatusNotFulfilledMock();
            var order        = new Order(notFulfilled, Guid.NewGuid())
            {
                Key = Guid.NewGuid()
            };

            //// Act
            _orderService.Save(order);

            //// Assert
            Assert.NotNull(_orderStatusInvokeTester.After);
            Assert.AreEqual(_orderStatusInvokeTester.After.Key, order.Key);
        }
示例#3
0
        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 Changing_Order_Status_Triggers_StatusChange_Events()
        {
            //// Arrange
            var notFulfilled = MockOrderStatusMaker.OrderStatusNotFulfilledMock();
            var fulfulled    = MockOrderStatusMaker.OrderStatusFulfilledMock();
            var order        = new Order(notFulfilled, Guid.NewGuid())
            {
                Key = Guid.NewGuid()
            };

            _orderService.Save(order);

            //// Act
            order.OrderStatus = fulfulled;
            _orderService.Save(order);

            //// Assert
            Assert.NotNull(Before, "Before was null");
            Assert.NotNull(After, "After was null");
            Assert.AreEqual(fulfulled.Key, Before.OrderStatusKey);
            Assert.AreEqual(fulfulled.Key, After.OrderStatusKey);
        }
示例#5
0
        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());
        }
示例#6
0
        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);
            }
        }