public void AddBankAccountThrowInvalidOperationExceptionWhenCustomerNotExist()
      {
         //Arrange
         var bankAccountRepository = new StubIBankAccountRepository();
         var customerRepository = new StubICustomerRepository();
         customerRepository.GetGuid = (guid) => { return null; };

         IBankTransferService transferService = new BankTransferService();

         var dto = new BankAccountDto()
         {
            CustomerId = Guid.NewGuid()
         };

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

         //Act
         bankingService.AddBankAccount(dto);
      }
      public void AddBankAccountReturnDtoWhenSaveSucceed()
      {
         //Arrange
         IBankTransferService transferService = new BankTransferService();

         var customerRepository = new StubICustomerRepository();
         customerRepository.GetGuid = (guid) =>
         {
            var customer = new Customer()
            {
               FirstName = "Jhon",
               LastName = "El rojo"
            };

            customer.ChangeCurrentIdentity(guid);

            return customer;
         };

         var bankAccountRepository = new StubIBankAccountRepository();
         bankAccountRepository.AddBankAccount = (ba) => { };
         bankAccountRepository.UnitOfWorkGet = () =>
         {
            var uow = new StubIUnitOfWork();
            uow.Commit = () => { };

            return uow;
         };

         var dto = new BankAccountDto()
         {
            CustomerId = Guid.NewGuid(),
            BankAccountNumber = "BA"
         };

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

         //Act
         var result = bankingService.AddBankAccount(dto);

         //Assert
         Assert.IsNotNull(result);

      }
      public void AddBankAccountReturnNullWhenCustomerIdIsEmpty()
      {
         //Arrange
         var bankAccountRepository = new StubIBankAccountRepository();
         var customerRepository = new StubICustomerRepository();
         IBankTransferService transferService = new BankTransferService();

         var dto = new BankAccountDto()
         {
            CustomerId = Guid.Empty
         };

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

         //Act
         var result = bankingService.AddBankAccount(dto);
      }
      public void AddBankAccountThrowArgumentNullExceptionWhenBankAccountDtoIsNull()
      {
         //Arrange
         var bankAccountRepository = new StubIBankAccountRepository();
         var customerRepository = new StubICustomerRepository();
         IBankTransferService transferService = new BankTransferService();

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

         //Act
         var result = bankingService.AddBankAccount(null);

         //Assert

         Assert.IsNull(result);
      }
        public void AddBankAccountReturnNullWhenBankAccountDTOIsNull()
        {
            //Arrange
            SIBankAccountRepository bankAccountRepository = new SIBankAccountRepository();
            SICustomerRepository customerRepository = new SICustomerRepository();
            IBankTransferService transferService = new BankTransferService();
            ITypeAdapter adapter = PrepareTypeAdapter();

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

            //Act
            var result = bankingService.AddBankAccount(null);

            //Assert

            Assert.IsNull(result);
        }
        public void AddBankAccountReturnDTOWhenSaveSucceed()
        {
            //Arrange
            IBankTransferService transferService = new BankTransferService();

            ITypeAdapter adapter = PrepareTypeAdapter();

            SICustomerRepository customerRepository = new SICustomerRepository();
            customerRepository.GetGuid = (guid) =>
            {
                return new Customer()
                {
                    Id = guid,
                    FirstName = "Jhon",
                    LastName = "El rojo"
                };
            };

            SIBankAccountRepository bankAccountRepository = new SIBankAccountRepository();
            bankAccountRepository.AddBankAccount = (ba) => { };
            bankAccountRepository.UnitOfWorkGet = () =>
            {
                var uow = new SIUnitOfWork();
                uow.Commit = () => { };

                return uow;
            };

            var dto = new BankAccountDTO()
            {
                CustomerId = Guid.NewGuid(),
                BankAccountNumber = "BA"
            };

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

            //Act
            var result = bankingService.AddBankAccount(dto);

            //Assert
            Assert.IsNotNull(result);
        }
        public void AddBankAccountReturnNullWhenCustomerNotExist()
        {
            //Arrange
            SIBankAccountRepository bankAccountRepository = new SIBankAccountRepository();
            SICustomerRepository customerRepository = new SICustomerRepository();
            customerRepository.GetGuid = (guid) => { return null; };

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

            var dto = new BankAccountDTO()
            {
                CustomerId = Guid.NewGuid()
            };

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

            //Act
            var result = bankingService.AddBankAccount(dto);

            //Assert

            Assert.IsNull(result);
        }