protected override void Context() { Username = "******"; base.Context(); AccountService.Stub( x => x.DeleteAccount(Arg<string>.Is.Equal(Username), Arg<DeleteAccountRequest>.Is.Anything)) .Return(new DeleteAccountResponse{Success = true,}); _accountReturnedFromQuickSearch = Builder<Account>.CreateNew().Build(); _responseFromQuickSearch = new SearchAccountsResponse { Accounts = new List<Account> { _accountReturnedFromQuickSearch, }, Success = true, }; AccountService.Stub( x => x.QuickSearchAccounts(Arg<string>.Is.Equal(Username), Arg<QuickSearchAccountsRequest>.Is.Anything)) .Return(_responseFromQuickSearch); _expectedViewModel = new AccountManagementViewModel(new List<string> {"User deleted successfully"}); _expectedViewModel.AddAccount(new AccountViewModel { Id = _accountReturnedFromQuickSearch.Id, EmailAddress = _accountReturnedFromQuickSearch.EmailAddress, FirstName = _accountReturnedFromQuickSearch.FirstName, LastName = _accountReturnedFromQuickSearch.LastName, UserName = _accountReturnedFromQuickSearch.Username, Role = _accountReturnedFromQuickSearch.Role.ToString(), }); }
protected override void Context() { base.Context(); _quickSearchAccountsRequest = new QuickSearchAccountsRequest { SearchString = "Bob 789 doorknob", }; AuthorizationService.Stub( x => x.CanExecute(Arg<string>.Is.Equal(Username), Arg<Type>.Is.Equal(typeof (QuickSearchAccountsRequest)))) .Return(true); _searchAccountsResponseReturnedFromRepository = new SearchAccountsResponse { Success = true, Accounts = Builder<Account>.CreateListOfSize(3).Build(), }; AccountRepository.Stub(x => x.QuickSearch(Arg<string>.Is.Equal(_quickSearchAccountsRequest.SearchString))) .Return(_searchAccountsResponseReturnedFromRepository); _expectedResponse = _searchAccountsResponseReturnedFromRepository; }
protected override void Context() { base.Context(); _searchAccountsRequest = Builder<SearchAccountsRequest>.CreateNew().Build(); AuthorizationService.Stub( x => x.CanExecute(Arg<string>.Is.Equal(Username), Arg<Type>.Is.Equal(typeof (SearchAccountsRequest)))) .Return(false); _expectedResponse = new SearchAccountsResponse { Success = false, Errors = new List<string> { "User is not authorized to Search Accounts", }, }; }
protected override void Context() { base.Context(); _searchAccountsRequest = Builder<SearchAccountsRequest>.CreateNew().Build(); AuthorizationService.Stub( x => x.CanExecute(Arg<string>.Is.Equal(Username), Arg<Type>.Is.Equal(typeof (SearchAccountsRequest)))) .Return(true); _searchAccountsResponseReturnedFromRepository = new SearchAccountsResponse { Accounts = new List<Account> { new Account(), new Account(), new Account(), }, }; AccountRepository.Stub(x => x.Search(Arg<SearchAccountsRequest>.Is.Equal(_searchAccountsRequest))) .Return(_searchAccountsResponseReturnedFromRepository); _expectedReponse = _searchAccountsResponseReturnedFromRepository; }
protected override void BecauseOf() { _response = AccountService.SearchAccounts(Username, _searchAccountsRequest); }