public async Task HandleAsync(DeleteExpenseTypeCommand message, CancellationToken token = default(CancellationToken)) { var type = await this.GetSavingTypeAsync(message.ExpenseTypeId); _types.Delete(type); await _types.SaveChangesAsync(); }
public async Task ShouldDeleteExisting() { // Arrange ExpenseType entity = ExpenseType.Create(Guid.NewGuid(), Guid.NewGuid(), "Name", "Symbol"); var repository = new Mock <IExpenseTypeRepository>(); repository.Setup(e => e.GetByIdAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(entity); DeleteExpenseTypeCommand cmd = new DeleteExpenseTypeCommand(entity.Id); ExpenseTypeCommandHandler actual = new ExpenseTypeCommandHandler(repository.Object); // Act await actual.HandleAsync(cmd); // Assert repository.Verify(e => e.Delete(It.Is <ExpenseType>(a => a.Equals(entity))), Times.Once ); }