public void AddOrderLineWithDiscount_OrderLineWithProductFound_UpdatedOrderLine( SalesOrder salesOrder, SalesOrderLine salesOrderLine, SpecialOfferProduct specialOfferProduct ) { //Arrange salesOrder.AddOrderLine( salesOrderLine.ProductNumber, salesOrderLine.ProductName, salesOrderLine.UnitPriceDiscount, 0, specialOfferProduct ); var orderLines = salesOrder.OrderLines.ToList(); var existingOrderLine = orderLines[0]; var originalQuantity = existingOrderLine.UnitPriceDiscount; //Act salesOrder.AddOrderLine( existingOrderLine.ProductNumber, existingOrderLine.ProductName, existingOrderLine.UnitPrice, existingOrderLine.UnitPriceDiscount + 1, specialOfferProduct ); //Assert orderLines.Count.Should().Be(1); orderLines[0].UnitPriceDiscount.Should().Be((short)(originalQuantity + 1)); }
public void Can_Get_TotalTax() { var purchaseOrderSut = new SalesOrder(); purchaseOrderSut.AddOrderLine(new OrderLineStubifier().GivenTax(5m).StubIt()); purchaseOrderSut.AddOrderLine(new OrderLineStubifier().GivenTax(1m).StubIt()); var totalTax = purchaseOrderSut.TotalTax(); Assert.AreEqual(5m + 1m, totalTax); }
public void Can_Get_TotalAfterTaxAmount() { var purchaseOrderSut = new SalesOrder(); purchaseOrderSut.AddOrderLine(new OrderLineStubifier().GivenAfterTaxAmount(25m).StubIt()); purchaseOrderSut.AddOrderLine(new OrderLineStubifier().GivenAfterTaxAmount(15m).StubIt()); var totalAfterTaxAmount = purchaseOrderSut.TotalAfterTaxAmount(); Assert.AreEqual(25m + 15m, totalAfterTaxAmount); }
public void AddOrderLine_NoOrderLinesWithProductFound_NewOrderLineWithQuantity( SalesOrder salesOrder, string productNumber, string productName, decimal unitPrice, SpecialOfferProduct specialOfferProduct, short quantity ) { //Arrange //Act salesOrder.AddOrderLine( productNumber, productName, unitPrice, 0, specialOfferProduct, quantity ); //Assert var orderLines = salesOrder.OrderLines.ToList(); orderLines.Count.Should().Be(1); orderLines[0].OrderQty.Should().Be(quantity); }
public void Can_Add_OrderLine() { var purchaseOrderSut = new SalesOrder(); purchaseOrderSut.AddOrderLine(new OrderLineStubifier().StubIt()); Assert.AreEqual(1, purchaseOrderSut.OrderLineCount()); }
public void Can_Print_Order_With_OrderLines() { var purchaseOrder = new SalesOrder(); purchaseOrder.AddOrderLine(new OrderLineStubifier().StubIt()); var outPuts = new SalesOrderPrinter(purchaseOrder).Print(); Assert.AreEqual(3, outPuts.Count); }
public async Task <bool> Handle(CreateSalesOrderCommand request, CancellationToken cancellationToken) { logger.LogInformation("----- Creating sales order"); logger.LogInformation("----- Creating OrderStarted domain event"); // Add Integration event to clean the basket var orderStartedIntegrationEvent = new OrderStartedIntegrationEvent(request.UserId); await salesOrderIntegrationEventService.AddAndSaveEventAsync(orderStartedIntegrationEvent); var customer = await GetCustomer(request.CustomerNumber); var creditCard = await GetCreditCard( request.CardType, request.CardNumber, request.CardExpiration ); var billToAddress = mapper.Map <Address>(request.BillToAddress); var shipToAddress = mapper.Map <Address>(request.ShipToAddress); var salesOrder = new SalesOrder(request.UserId, request.UserName, customer, request.ShipMethod, billToAddress, shipToAddress, creditCard, request.CardSecurityNumber, request.CardHolderName); foreach (var item in request.OrderItems) { var specialOfferProduct = await specialOfferProductRepository .GetBySpecAsync( new GetSpecialOfferProductSpecification(item.ProductNumber), cancellationToken ); Guard.Against.Null(specialOfferProduct, nameof(specialOfferProduct)); salesOrder.AddOrderLine(item.ProductNumber, item.ProductName, item.UnitPrice, item.Discount, specialOfferProduct, item.Quantity); } logger.LogInformation("----- Saving sales order to database - Sales Order: {@SalesOrder}", salesOrder); await salesOrderRepository.AddAsync(salesOrder, cancellationToken); logger.LogInformation("Sales order was created succesfully"); return(true); }