public void UpdateGroceriesCommandHandlerShouldReturnNotifications() { var _mock = MockRepository.GenerateMock <IGroceriesRepository>(); string originalName = "TestGrocery"; var command = new UpdateGroceriesCommand() { Id = Guid.NewGuid(), Name = "Te", //Invalid name Price = 10, Unity = Enums.Unity.Liters, Category = Enums.Category.BakingGoods }; _mock.Expect(x => x.GetById(command.Id)).Return(new Groceries(command.Id, originalName, command.Price, command.Unity, command.Category)); UpdateGroceriesCommandHandler handler = new UpdateGroceriesCommandHandler(_mock); var g = handler.Handle(command); Assert.AreNotEqual(handler.Notifications.Count, 0); }
public async Task <IActionResult> Put(Guid id, [FromBody] UpdateGroceriesCommand updateGroceriesCommand) { var result = _updateGroceriesCommandHandler.Handle(updateGroceriesCommand); return(await Response(result, _updateGroceriesCommandHandler.Notifications)); }