Exemplo n.º 1
0
        private async Task HandleBankAccountCreatedEvent(BankAccountCreatedEvent @event)
        {
            var newBankAccount = new BankAccount
            {
                Id = @event.EntityId.ToString(),
                AccountHolderName = @event.Name,
                Balance           = 0.0m
            };

            repositoryFacade.BankAccountRepository.Insert(newBankAccount);
            await repositoryFacade.Save();
        }
Exemplo n.º 2
0
        public void Open(string name)
        {
            if (Id != default)
            {
                return;
            }

            var newAccountId = new AccountId();
            var @event       = new BankAccountCreatedEvent(
                name,
                newAccountId.Value
                );

            Apply(@event);
        }
Exemplo n.º 3
0
        public async void WhenABankAccountCreatedEventIsReceived_ThenANewBankAccountIsSaved()
        {
            var bankAccountId           = new AccountId();
            var bankAccountCreatedEvent = new BankAccountCreatedEvent("John Doe", bankAccountId.Value, 1);

            var jsonData = JsonConvert.SerializeObject(bankAccountCreatedEvent);
            await readerStoreEventHandler.Run(jsonData, 1, DateTime.UtcNow, "1", mockLogger.Object);

            mockRepositoryFacade.MockRepositoryFacade.Verify(
                mock => mock.BankAccountRepository.Insert(
                    It.Is <Banking.QueryProcessor.Domain.BankAccount.BankAccount>(
                        bankAccount =>
                        bankAccount.Id == bankAccountId.Value.ToString() &&
                        bankAccount.AccountHolderName == "John Doe"
                        )
                    )
                );
        }