Пример #1
0
        public void Can_create_UnblockedAccount_Command()
        {
            var id       = Guid.NewGuid();
            var @command = new UnblockAccount(id);

            Assert.NotNull(@command);
            Assert.Equal(id, @command.AccountId);
        }
Пример #2
0
        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());
        }
Пример #3
0
        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());
        }