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)); }
public ActionResult NewAccount(AccountFilterModel filter, FormCollection collection) { var account = new AccountModel(); try { UpdateModel(account); AccountServices.CreateAccount(account); return(RedirectToAction("AccountListing", filter.GenerateAccountListingRoute())); } catch (Exception ex) { // Invalid - redisplay with errors Logger.Error(ex.ToString()); ModelState.AddModelError(String.Empty, Constants.ServerError); var model = new AccountDetailModel() { Action = "NewAccount", Account = account, Filter = filter }; ViewBag.AccountTypes = AccountTypeServices.GetAccountTypes(false, account.AccountTypeId); ViewBag.StateCodes = LookupServices.GetStateOptions(account.StateCode); return(View("AccountDetail", model)); } }
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); }