public void LockBankAccountReturnFalseIfBankAccountNotExist() { //Arrange var customerRepository = new Mock <ICustomerRepository>(); IBankTransferService transferService = new BankTransferService(); Mock <MainBCUnitOfWork> _mockContext = new Mock <MainBCUnitOfWork>(); _mockContext.Setup(c => c.Commit()); var bankAccountRepository = new Mock <IBankAccountRepository>(); bankAccountRepository .Setup(x => x.UnitOfWork).Returns(_mockContext.Object); bankAccountRepository .Setup(x => x.Get(It.IsAny <Guid>())) .Returns((Guid guid) => null); Mock <ILogger <BankAppService> > _mockLogger = new Mock <ILogger <BankAppService> >(); IBankAppService bankingService = new BankAppService(bankAccountRepository.Object, customerRepository.Object, transferService, _mockLogger.Object); //Act var result = bankingService.LockBankAccount(Guid.NewGuid()); //Assert Assert.False(result); }
public void LockBankAccountReturnFalseIfIdentifierIsEmpty() { //Arrange var bankAccountRepository = new Mock <IBankAccountRepository>(); bankAccountRepository .Setup(x => x.Get(It.IsAny <Guid>())) .Returns((Guid guid) => guid == Guid.Empty ? null : new BankAccount { }); var customerRepository = new Mock <ICustomerRepository>(); IBankTransferService transferService = new BankTransferService(); Mock <ILogger <BankAppService> > _mockLogger = new Mock <ILogger <BankAppService> >(); IBankAppService bankingService = new BankAppService(bankAccountRepository.Object, customerRepository.Object, transferService, _mockLogger.Object); //Act var result = bankingService.LockBankAccount(Guid.Empty); //Assert Assert.False(result); }
public void LockBankAccountReturnFalseIfIdentifierIsEmpty() { //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.LockBankAccount(Guid.Empty); //Assert Assert.IsFalse(result); }
public void LockBankAccountReturnFalseIfBankAccountNotExist() { //Arrange SICustomerRepository customerRepository = new SICustomerRepository(); IBankTransferService transferService = new BankTransferService(); SIBankAccountRepository bankAccountRepository = new SIBankAccountRepository(); bankAccountRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); uow.Commit = () => { }; return(uow); }; bankAccountRepository.GetGuid = (guid) => { return(null); }; IBankAppService bankingService = new BankAppService(bankAccountRepository, customerRepository, transferService); //Act var result = bankingService.LockBankAccount(Guid.NewGuid()); //Assert Assert.IsFalse(result); }
public void LockBankAccountReturnTrueIfBankAccountIsLocked() { //Arrange var customerRepository = new Mock <ICustomerRepository>(); IBankTransferService transferService = new BankTransferService(); var bankAccountRepository = new Mock <IBankAccountRepository>(); Mock <MainBCUnitOfWork> _mockContext = new Mock <MainBCUnitOfWork>(); _mockContext.Setup(c => c.Commit()); bankAccountRepository .Setup(x => x.UnitOfWork).Returns(_mockContext.Object); bankAccountRepository .Setup(x => x.Get(It.IsAny <Guid>())) .Returns((Guid guid) => { var customer = new Customer(); customer.GenerateNewIdentity(); var bankAccount = new BankAccount(); bankAccount.GenerateNewIdentity(); bankAccount.SetCustomerOwnerOfThisBankAccount(customer); return(bankAccount); }); Mock <ILogger <BankAppService> > _mockLogger = new Mock <ILogger <BankAppService> >(); IBankAppService bankingService = new BankAppService(bankAccountRepository.Object, customerRepository.Object, transferService, _mockLogger.Object); //Act var result = bankingService.LockBankAccount(Guid.NewGuid()); //Assert Assert.True(result); }
public void LockBankAccountReturnTrueIfBankAccountIsLocked() { //Arrange var customerRepository = new StubICustomerRepository(); IBankTransferService transferService = new BankTransferService(); var bankAccountRepository = new StubIBankAccountRepository(); bankAccountRepository.UnitOfWorkGet = () => { var uow = new StubIUnitOfWork(); uow.Commit = () => { }; return(uow); }; bankAccountRepository.GetGuid = (guid) => { var customer = new Customer(); customer.GenerateNewIdentity(); var bankAccount = new BankAccount(); bankAccount.GenerateNewIdentity(); bankAccount.SetCustomerOwnerOfThisBankAccount(customer); return(bankAccount); }; IBankAppService bankingService = new BankAppService(bankAccountRepository, customerRepository, transferService); //Act var result = bankingService.LockBankAccount(Guid.NewGuid()); //Assert Assert.IsTrue(result); }