Пример #1
0
        public GetCustomersResponse GetCustomersByCriteria(GetCustomersRequest request)
        {
            GetCustomersResponse response = new GetCustomersResponse();
            CustomerBusinessComponent bc = DependencyInjectionHelper.GetCustomerBusinessComponent();

            IQueryable<Customer> customers = bc.GetCustomersByCriteria(request.SearchType, request.City, request.CustomerName);
            response.Customers = CustomerAdapter.CustomersToDtos(customers);

            return response;
        }
        public void TestGetCustomers()
        {
            int customerId = 1;
            GetCustomersResponse response = new GetCustomersResponse();
            response.Customers.Add(new CustomerListDTO() {Id = customerId});

            Expect.Once.On(service).Method("GetCustomersByCriteria").Will(Return.Value(response));
            IList<CustomerListDTO> customers = serviceFacade.GetCustomersByCity("FakeCity");
            Assert.AreEqual(1, customers.Count);
            Assert.AreEqual(customers.First().Id, customerId);

            Expect.Once.On(service).Method("GetCustomersByCriteria").Will(Return.Value(response));
            customers = serviceFacade.GetCustomersByName("FAkeName");
            Assert.AreEqual(1, customers.Count);
            Assert.AreEqual(customers.First().Id, customerId);

            Expect.Once.On(service).Method("GetCustomersByCriteria").Will(Return.Value(response));
            customers = serviceFacade.GetAllCustomers();
            Assert.AreEqual(1, customers.Count);
            Assert.AreEqual(customers.First().Id, customerId);
        }