示例#1
0
        public async void WhenAMakeDepositEventIsReceived_ThenATheBankAccountBalanceIsUpdated()
        {
            var accountId       = Guid.NewGuid();
            var mockBankAccount = new Banking.QueryProcessor.Domain.BankAccount.BankAccount
            {
                Id = accountId.ToString()
            };

            mockRepositoryFacade.MockBankAccountRepository
            .Setup(mock => mock.Get(mockBankAccount.Id))
            .Returns(Task.Run(() => mockBankAccount));

            var depositMadeEvent = new DepositMadeEvent(Guid.NewGuid(), "A Deposit", 123.45m, accountId, 1);

            var jsonData = JsonConvert.SerializeObject(depositMadeEvent);

            await readerStoreEventHandler.Run(jsonData, 1, DateTime.UtcNow, "1", mockLogger.Object);

            mockRepositoryFacade.MockRepositoryFacade.Verify(
                mock => mock.BankAccountRepository.Update(It.Is <Banking.QueryProcessor.Domain.BankAccount.BankAccount>(
                                                              bankAccount =>
                                                              bankAccount.Balance == 123.45m
                                                              )
                                                          )
                );
        }
示例#2
0
        public async void WhenAMakeDepositEventIsReceived_ThenADepositIsSaved()
        {
            var accountId       = Guid.NewGuid();
            var mockBankAccount = new Banking.QueryProcessor.Domain.BankAccount.BankAccount
            {
                Id = accountId.ToString()
            };

            mockRepositoryFacade.MockBankAccountRepository
            .Setup(mock => mock.Get(mockBankAccount.Id))
            .Returns(Task.Run(() => mockBankAccount));

            var depositMadeEvent = new DepositMadeEvent(Guid.NewGuid(), "A Deposit", 123.45m, accountId, 1);

            var jsonData = JsonConvert.SerializeObject(depositMadeEvent);

            await readerStoreEventHandler.Run(jsonData, 1, DateTime.UtcNow, "1", mockLogger.Object);

            mockRepositoryFacade.MockRepositoryFacade.Verify(
                mock => mock.TransactionsRepository.Insert(It.Is <Transaction>(
                                                               transaction =>
                                                               transaction.BankAccount.Id == mockBankAccount.Id &&
                                                               transaction.Description == depositMadeEvent.Description &&
                                                               transaction.Id == depositMadeEvent.EntityId.ToString() &&
                                                               transaction.Amount == depositMadeEvent.Amount &&
                                                               transaction.Type == TransactionType.Deposit
                                                               )
                                                           )
                );
        }