Beispiel #1
0
        public void Order_SavesOrder()
        {
            //Arrange
            var       product  = _service.GetAvailableProducts(_order).First();
            const int quantity = 1;

            _order.AddLineItem(quantity, product);
            OrderDto dto = null;

            _repo.Setup(repo => repo.CreateOrder(It.IsAny <OrderDto>()))
            .Callback <OrderDto>(x => dto = x);

            //Act
            _service.SubmitOrder(_order);

            //Assert
            dto.ShouldNotBeNull();
            dto.Customer.ShouldBe(_customer);
            dto.TotalPrice.ShouldBe(_order.TotalPrice);
            dto.LineItems.Count.ShouldBe(1);
            var lineItem = dto.LineItems.Single();

            lineItem.Product.ShouldBe(product);
            lineItem.Quantity.ShouldBe(quantity);
        }