コード例 #1
0
      public void FindBankAccountActivitiesReturnAllItems()
      {
         //Arrange
         var bankAccountRepository = new StubIBankAccountRepository();
         bankAccountRepository.GetGuid = (guid) =>
         {
            var bActivity1 = new BankAccountActivity()
            {
               Date = DateTime.Now,
               Amount = 1000
            };
            bActivity1.GenerateNewIdentity();

            var bActivity2 = new BankAccountActivity()
            {
               Date = DateTime.Now,
               Amount = 1000
            };
            bActivity2.GenerateNewIdentity();

            var bankAccount = new BankAccount()
            {
               BankAccountActivity = new HashSet<BankAccountActivity>()
               {
                  bActivity1,
                  bActivity2
               }
            };
            bankAccount.GenerateNewIdentity();

            return bankAccount;
         };

         var customerRepository = new StubICustomerRepository();
         IBankTransferService transferService = new BankTransferService();

         IBankAppService bankingService = new BankAppService(bankAccountRepository, customerRepository, transferService);

         //Act
         var result = bankingService.FindBankAccountActivities(Guid.NewGuid());

         //Assert
         Assert.IsNotNull(result);
         Assert.IsTrue(result.Count == 2);
      }
コード例 #2
0
      public void FindBankAccountActivitiesReturnNullWhenBankAccountNotExists()
      {
         //Arrange

         var bankAccountRepository = new StubIBankAccountRepository();
         bankAccountRepository.GetGuid = (guid) => { return null; };
         var customerRepository = new StubICustomerRepository();
         IBankTransferService transferService = new BankTransferService();

         IBankAppService bankingService = new BankAppService(bankAccountRepository, customerRepository, transferService);

         //Act
         var result = bankingService.FindBankAccountActivities(Guid.NewGuid());

         //Assert
         Assert.IsNull(result);
      }
コード例 #3
0
        public void FindBankAccountActivitiesReturnNullWhenBankAccountIdIsEmpty()
        {
            //Arrange

            SIBankAccountRepository bankAccountRepository = new SIBankAccountRepository();
            SICustomerRepository customerRepository = new SICustomerRepository();
            IBankTransferService transferService = new BankTransferService();
            ITypeAdapter adapter = new SITypeAdapter();

            IBankAppService bankingService = new BankAppService(bankAccountRepository, customerRepository, transferService, adapter);

            //Act
            var result = bankingService.FindBankAccountActivities(Guid.Empty);

            //Assert
            Assert.IsNull(result);
        }
コード例 #4
0
      public void FindBankAccountActivitiesReturnNullWhenBankAccountIdIsEmpty()
      {
         //Arrange

         var bankAccountRepository = new StubIBankAccountRepository();
         bankAccountRepository.GetGuid = guid =>
         {
            if (guid == Guid.Empty) {
               return null;
            }
            else
            {
               return new BankAccount
               {
               };
            }
         };
         var customerRepository = new StubICustomerRepository();
         IBankTransferService transferService = new BankTransferService();

         IBankAppService bankingService = new BankAppService(bankAccountRepository, customerRepository, transferService);

         //Act
         var result = bankingService.FindBankAccountActivities(Guid.Empty);

         //Assert
         Assert.IsNull(result);
      }
コード例 #5
0
        public void FindBankAccountActivitiesReturnAllItems()
        {
            //Arrange
            SIBankAccountRepository bankAccountRepository = new SIBankAccountRepository();
            bankAccountRepository.GetGuid = (guid) =>
            {
                var bankAccount = new BankAccount()
                {
                    Id = Guid.NewGuid(),
                    BankAccountActivity = new HashSet<BankAccountActivity>()
                    {
                        new BankAccountActivity(){Id = Guid.NewGuid(),Date = DateTime.Now,Amount = 1000},
                        new BankAccountActivity(){Id = Guid.NewGuid(),Date = DateTime.Now,Amount = 1000},
                    }
                };

                return bankAccount;
            };

            SICustomerRepository customerRepository = new SICustomerRepository();
            IBankTransferService transferService = new BankTransferService();
            ITypeAdapter adapter = PrepareTypeAdapter();

            IBankAppService bankingService = new BankAppService(bankAccountRepository, customerRepository, transferService, adapter);

            //Act
            var result = bankingService.FindBankAccountActivities(Guid.NewGuid());

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 2);
        }