public void CreateAccount_AccountDtoIsNull() { //arrange IRepository repository = MockRepository.GenerateStub<IRepository>(); IAccountRepository accountRepository = MockRepository.GenerateStub<IAccountRepository>(); ICustomerRepository thirdPartyRepository = MockRepository.GenerateStub<ICustomerRepository>(); IDtoCreator<Account, AccountDto> accountCreator = new AccountDtoCreator(); //act IAccountServices services = new AccountServices(repository, accountRepository, thirdPartyRepository, accountCreator); services.CreateAccount(null, 0,0); }
public void CreateAccount_itNotFound() { //arrange IRepository repository = MockRepository.GenerateStub<IRepository>(); IAccountRepository accountRepository = MockRepository.GenerateStub<IAccountRepository>(); ICustomerRepository thirdPartyRepository = MockRepository.GenerateStub<ICustomerRepository>(); IDtoCreator<Account, AccountDto> accountCreator = new AccountDtoCreator(); string accountName = "Account Name"; //act IAccountServices services = new AccountServices(repository, accountRepository, thirdPartyRepository, accountCreator); services.CreateAccount(accountName, 1,0); }
public void CreateAccount_ok() { //arrange IRepository repository = MockRepository.GenerateStub<IRepository>(); IAccountRepository accountRepository = MockRepository.GenerateStub<IAccountRepository>(); ICustomerRepository thirdPartyRepository = MockRepository.GenerateStub<ICustomerRepository>(); IDtoCreator<Account, AccountDto> accountCreator = new AccountDtoCreator(); string accountName = "name"; Customer customer = new Customer() { Id = 1 }; Role role = new Role { Id = 1 }; repository.Expect(x => x.Get<Customer>(customer.Id)).Return(customer); repository.Expect(x => x.Get<Role>(role.Id)).Return(role); //act IAccountServices services = new AccountServices(repository, accountRepository, thirdPartyRepository, accountCreator); services.CreateAccount(accountName, customer.Id,role.Id); //assert repository.VerifyAllExpectations(); repository.AssertWasCalled(x => x.SaveOrUpdate<Customer>(customer)); repository.AssertWasCalled(x => x.Save<Account>(Arg<Account>.Is.NotNull)); }