예제 #1
0
        public void CreateOrder_PaidInFull()
        {
            //var customerCreditLimitReached = new Mock<ICustomerCreditLimitReached>();
            //customerCreditLimitReached.Setup(x => x.IsSatisfiedBy(It.IsAny<Order>())).Returns(false);
            var customer = CustomerTests.DefaulCustomer(new Mock <IDuplicateCustomerEmail>().Object);

            Repository(s => s.Add(customer));

            Repository(r => r.Add(DefaultOrder(customerId: customer.CustomerId)));

            var domain     = DefaultOrder(customerId: customer.CustomerId);
            var orderValue = 11.95m;

            Repository(repository =>
            {
                var customerCreditLimitReached = new CustomerCreditLimitReached(repository);

                domain.AddOrderLine("Test Product", 1, orderValue);
                domain.ProcessingOrder(customerCreditLimitReached);
                domain.AddPayment(DateTime.Now, orderValue, true);

                repository.Add(domain);
            });

            Repository(repository =>
            {
                var order = repository.Load <Order>(x => x.OrderId == domain.OrderId,
                                                    i => i.OrderLines,
                                                    i => i.OrderPayments);

                Assert.AreEqual(orderValue, order.TotalValue);
                Assert.AreEqual(orderValue, order.TotalPaid);
            });
        }
예제 #2
0
        public void CreateOrder()
        {
            var customerId       = new CustomerId(Guid.NewGuid().ToString());
            var customerFullName = "Test Customer";
            var domain           = DefaultOrder(customerId, customerFullName);

            domain.AddOrderLine("Test Product", 1, 10.95m);

            var customer = CustomerTests.DefaulCustomer(_duplicateCustomerEmail.Object);

            Repository(repository =>
            {
                repository.Add(customer);
                repository.Add(domain);
            });

            Repository(repository =>
            {
                var order = repository.Load <Order>(x => x.OrderId == domain.OrderId,
                                                    i => i.OrderLines);

                Assert.NotNull(order);
                Assert.NotNull(order.OrderLines);
                Assert.AreEqual(customerId, order.CustomerId);
                Assert.AreEqual(customerFullName, order.CustomerFullName);
                Assert.AreEqual(1, order.OrderLines.Count);
            });
        }