public void DeleteGroceriesCommandHandlerShouldntReturnNotification() { var _mock = MockRepository.GenerateMock <IGroceriesRepository>(); var command = new DeleteGroceriesCommand(Guid.NewGuid()); _mock.Expect(x => x.GetById(command.Id)).Return(new Groceries(command.Id, "Test3", 30, Unity.Unity, Category.Beverages)); DeleteGroceriesCommandHandler handler = new DeleteGroceriesCommandHandler(_mock); var g = handler.Handle(command); Assert.AreEqual(handler.Notifications.Count, 0); }
public void DeleteGroceriesCommandHandlerShoulReturnNotification() { var _mock = MockRepository.GenerateMock <IGroceriesRepository>(); var command = new DeleteGroceriesCommand(Guid.NewGuid()); _mock.Expect(x => x.GetById(command.Id)).Return(null); DeleteGroceriesCommandHandler handler = new DeleteGroceriesCommandHandler(_mock); var g = handler.Handle(command); Assert.AreNotEqual(handler.Notifications.Count, 0); }
public async Task <IActionResult> Delete(Guid id) { var result = _deleteGroceriesCommandHandler.Handle(new DeleteGroceriesCommand(id)); return(await Response(result, _deleteGroceriesCommandHandler.Notifications)); }