public void Can_create_BlockAccount_Command() { var id = Guid.NewGuid(); var @command = new BlockAccount(id); Assert.NotNull(@command); Assert.Equal(id, @command.AccountId); }
public async Task <BlockAccountResult> GetBlockAccountAsync(string hash) { var action = new BlockAccount { Hash = hash }; var handler = new ActionHandler <BlockAccount, BlockAccountResult>(_node); return(await handler.Handle(action)); }
public void Can_block_Account() { var id = Guid.NewGuid(); var createCommand = new CreateAccount(id, "someone"); var reply = _service.Handle(createCommand); var account = _repo.GetById <TestAccount>(id); var blockCommand = new BlockAccount(id); Assert.Equal(typeof(Success), _service.Handle(blockCommand).GetType()); }
public CommandResponse Handle(BlockAccount command) { if (!_repository.TryGetById <AccountAggregate.BankAccount>(command.AccountId, out var account)) { throw new InvalidOperationException("No account with such ID"); } account.Block(new Blocked(command.AccountId)); _repository.Save(account); return(command.Succeed()); }