protected override void Context()
        {
            base.Context();

            _quickSearchCustomersRequest = Builder<QuickSearchCustomersRequest>.CreateNew().Build();

            AuthorizationService.Stub(
                x => x.CanExecute(Arg<string>.Is.Equal(Username), Arg<Type>.Is.Equal(typeof(QuickSearchCustomersRequest))))
                .Return(true);

            var franchise = Builder<Customer>.CreateNew().Build();
            franchise.AddContact(Builder<Contact>.CreateNew().Build());
            _franchisesReturnedFromRepository = new List<Customer>
                                                    {
                                                        franchise,
                                                        franchise,
                                                        franchise,
                                                    };

            CustomerRepository.Stub(x => x.QuickSearch(Arg<string>.Is.Equal(_quickSearchCustomersRequest.SearchString)))
                .Return(_franchisesReturnedFromRepository);

            _expectedResult = _franchisesReturnedFromRepository;
        }
Exemplo n.º 2
0
        private IEnumerable<Customer> QuickSearchCustomers(string username,
                                                           QuickSearchCustomersRequest quickSearchCustomersRequest)
        {
            if (!_authorizationService.CanExecute(username, "ViewCustomers"))
                throw new SecurityException("User is not authorized to View Customers.");

            return _customerRepository.QuickSearch(quickSearchCustomersRequest.SearchString);
        }