public void RemoveBankAccountCommandFail() { var cmd = new RemoveBankAccountCommand(_id, Guid.NewGuid()); _handler.Handle(cmd); Assert.IsFalse(_handler.Valid, _handler.Notifications.FirstOrDefault().Message); }
public Task<bool> Handle(RemoveBankAccountCommand command) { var entity = _repository.Get(command.Id); if (entity == null) { AddNotification("correntista", "Correntista não localizado"); return Task.FromResult(true); } var bankAccount = entity.Accounts.SingleOrDefault(n => n.Id == command.AccountId); if (bankAccount == null) { AddNotification("conta-corrente", "Conta não localizada"); ; return Task.FromResult(false); } entity.RemoveAccount(bankAccount); _repository.Update(entity); _uow.Commit(); return Task.FromResult(true); }