public async void GetPriceOnOrderHandlerFailure() { var mockOrder = new MockOrderData(); var createOrder = mockOrder.AddItemToOrder(1); GetPriceOnOrderQuery getPriceOnOrderQuery = new GetPriceOnOrderQuery(createOrder.OrderId); GetPriceOnOrderHandler getPriceOnOrderHandler = new GetPriceOnOrderHandler(); var actual = await getPriceOnOrderHandler.Handle(getPriceOnOrderQuery, new CancellationToken()); var expected = 20; Assert.NotEqual(expected, actual); }
public async void AddIngredientsHandlerFailure() { AddIngredientsHandler addIngredientsHandler = new AddIngredientsHandler(); MockOrderData mockData = new MockOrderData(); var itemOrder = mockData.AddItemToOrder(5); var itemId = itemOrder.Items.Select(x => x.OrderItemId).FirstOrDefault(); AddIngredientsCommand addIngredientsCommand = new AddIngredientsCommand(itemId, 4, itemOrder.OrderId); var order = await addIngredientsHandler.Handle(addIngredientsCommand, new CancellationToken()); var actual = order.Error; var expected = false; Assert.NotEqual(expected, actual); }
public async void RemoveProductFromOrderHandlerFailure() { var mockOrder = new MockOrderData(); var createOrder = mockOrder.AddItemToOrder(4); RemoveProductFromOrderCommand removeProductFromOrderCommand = new RemoveProductFromOrderCommand(createOrder.Items[0].OrderItemId, createOrder.OrderId); RemoveProductFromOrderHandler removeProductFromOrderHandler = new RemoveProductFromOrderHandler(); var actual = await removeProductFromOrderHandler.Handle(removeProductFromOrderCommand, new CancellationToken()); var actualbool = actual.Error; var expectedbool = true; Assert.NotEqual(expectedbool, actualbool); }
public async void AddIngredientsHandlerSuccess() { AddIngredientsHandler addIngredientsHandler = new AddIngredientsHandler(); MockOrderData mockData = new MockOrderData(); var itemOrder = mockData.AddItemToOrder(1); var itemId = itemOrder.Items.Select(x => x.OrderItemId).FirstOrDefault(); AddIngredientsCommand addIngredientsCommand = new AddIngredientsCommand(itemId, 4, itemOrder.OrderId); var order = await addIngredientsHandler.Handle(addIngredientsCommand, new CancellationToken()); var orderIngredients = order.Data.Items.Where(x => x.Cost > 0).ToList(); var actualName = order.Data.Items.FirstOrDefault(); var numberOfExtraIngredients = actualName.Ingredients.Where(c => c.Cost > 0).ToList().Count(); var expected = 1; Assert.Equal(expected, numberOfExtraIngredients); }