Beispiel #1
0
        public void TestRevertOrder()
        {
            var incomeSumBefore = _incomesForProduct.Sum(x => x.QuantityCurrent);

            var outcome1 = new Outcome(_product.Price, 10, _incomesForProduct[0], 0);
            var outcome2 = new Outcome(_product.Price, 5, _incomesForProduct[1], 0);
            var outcomes = new List<Outcome>() {outcome1, outcome2};
            var orderLine = new OrderLine(_product, 15, outcomes);

            _incomesForProduct[0].QuantityCurrent -= 10;
            _incomesForProduct[0].QuantityCurrent -= 5;

            Order order = new Order(outcomes, new List<OrderLine>(){orderLine});

            Assert.True(order.Outcomes().Sum(x => x.Quantity) == 15);

            _orderService.RevertOrder(order);

            Assert.True(_incomesForProduct.Sum(x => x.QuantityCurrent) == incomeSumBefore);
            Assert.True(order.Outcomes().Count() == 0);
            Assert.True(order.Status.Equals(OrderStatus.Revoked));
        }
Beispiel #2
0
        public virtual OrderLine AddOrderLine(Product product, int quantity, List<Outcome> outcomes)
        {
            OrderLine orderLine = new OrderLine(product, quantity, outcomes);
            orderLine.Price = product.Price;
            orderLine.ProductName = product.Name;

            Lines.Add(orderLine);
            return orderLine;
        }