public void Can_create_UnblockedAccount_Command() { var id = Guid.NewGuid(); var @command = new UnblockAccount(id); Assert.NotNull(@command); Assert.Equal(id, @command.AccountId); }
public void Can_unblock_Account() { var id = Guid.NewGuid(); var createCommand = new CreateAccount(id, "someone"); var reply = _service.Handle(createCommand); var unblockCommand = new UnblockAccount(id); Assert.Equal(typeof(Success), _service.Handle(unblockCommand).GetType()); }
public CommandResponse Handle(UnblockAccount command) { if (!_repository.TryGetById <AccountAggregate.BankAccount>(command.AccountId, out var account)) { throw new InvalidOperationException("No account with such ID"); } account.Unblock(new Unblocked(command.AccountId)); _repository.Save(account); return(command.Succeed()); }