public async Task EditOrderCommandHandler_UpdatesExistingOrder() { //Arrange Shop seller = new Shop(); Customer buyer = new Customer(); AllMarktContextIM.Shops.Add(seller); AllMarktContextIM.Customers.Add(buyer); await AllMarktContextIM.SaveChangesAsync(); var order = new AllMarkt.Entities.Order { Seller = seller, Buyer = buyer, AdditionalNotes = "Test Notes", DeliveryAddress = "Test Address", DeliveryPhoneNumber = "01234567890", TotalPrice = 1, TimeOfOrder = DateTime.Now, OrderStatus = Status.Registered, AWB = "Test AWB", }; OrderItem orderItem = new OrderItem { Order = order }; order.OrderItems = new List <OrderItem> { orderItem }; AllMarktContextIM.Orders.Add(order); AllMarktContextIM.OrderItems.Add(orderItem); await AllMarktContextIM.SaveChangesAsync(); var existingOrder = AllMarktContextIM.Orders.Where(o => o.Id == order.Id).FirstOrDefault(); var editOrderCommand = new EditOrderCommand { Id = existingOrder.Id, AdditionalNotes = "Test Notes", DeliveryAddress = "Edit Address", DeliveryPhoneNumber = "0123456789", TotalPrice = 1, OrderStatus = Status.Registered, AWB = "Edit AWB" }; //Act await _editOrderCommandHandler.Handle(editOrderCommand, CancellationToken.None); // AllMarktContextIM.Orders.Should().Contain(x => x.Id == editOrderCommand.Id); order.DeliveryAddress.Should().Be(editOrderCommand.DeliveryAddress); order.AWB.Should().Be(editOrderCommand.AWB); }
public async Task GetShopOrdersQueryHandle_Returns_ExistingOrders() { //Arrange AllMarkt.Entities.Shop seller = new AllMarkt.Entities.Shop { Address = "aaaaa", Comments = null, CUI = "aaaaddd", IBAN = "aaaaa", Orders = null, PhoneNumber = "0123654789", ProductCategories = null, ShopCategoryLink = null, SocialCapital = 4 }; AllMarktContextIM.Shops.Add(seller); await AllMarktContextIM.SaveChangesAsync(); AllMarkt.Entities.Order order = new AllMarkt.Entities.Order() { Seller = seller }; AllMarktContextIM.Orders.Add(order); await AllMarktContextIM.SaveChangesAsync(); //Act var result = await _getShopOrdersQueryHandler .Handle(new GetShopOrdersQuery() { ShopId = seller.Id }, CancellationToken.None); //Assert result.Count().Should().Be(1); }
public async Task GetAllOrdersQueryHandler_Returns_ExistingOrders() { //Arrange AllMarkt.Entities.Order order = new AllMarkt.Entities.Order(); AllMarktContextIM.Orders.Add(order); await AllMarktContextIM.SaveChangesAsync(); //Act var result = await _getAllOrdersQueryHandler.Handle(new GetAllOrdersQuery(), CancellationToken.None); //Assert result.Count().Should().Be(1); }
private ICollection <OrderItem> GetOrderItems(ICollection <OrderItemViewModel> orderItems, AllMarkt.Entities.Order order) { List <OrderItem> result = new List <OrderItem>(); foreach (var orderItemVM in orderItems) { var orderItem = new OrderItem(); orderItem.Id = orderItemVM.Id; orderItem.Name = orderItemVM.Name; orderItem.Amount = orderItemVM.Amount; orderItem.Price = orderItemVM.Price; orderItem.Order = order; result.Add(orderItem); } return(result); }