Esempio n. 1
0
        public void Can_create_BlockAccount_Command()
        {
            var id       = Guid.NewGuid();
            var @command = new BlockAccount(id);

            Assert.NotNull(@command);
            Assert.Equal(id, @command.AccountId);
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
        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());
        }