Ejemplo n.º 1
0
        public SecuredCustomerServiceProxy()
        {
            var httpApplication = HttpContext.Current.Application;

            if (httpApplication != default(HttpApplicationState))
            {
                string[] credentials = ( string[] )httpApplication.Get("ServiceCredentials");

                customerServiceProxy = new CustomerServiceProxy(credentials[0], credentials[1]);
            }
        }
        public CustomerControllerTests()
        {
            var configurationManager = new Mock <IConfigurationManager>();
            var httpHandler          = new Mock <IHttpHandler>();

            _mapper = new Mock <IMapper>();

            httpHandler.Setup(a => a.GetString("test")).Returns("[{\"id\": 1,\"name\": \"Rob\"}]");
            configurationManager.Setup(a => a.CustomerServiceUrl).Returns("test");

            var customerServiceProxy = new CustomerServiceProxy(configurationManager.Object, httpHandler.Object, _mapper.Object);

            _customerController = new CustomerController(customerServiceProxy);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var customerServiceProxy = new CustomerServiceProxy();
            var filteredCustomers    = customerServiceProxy.GetCustomers("wind");

            foreach (var customer in filteredCustomers)
            {
                Console.WriteLine(customer.ToString());
            }
            Console.WriteLine();
            var orderServiceProxy = new OrderServiceProxy();
            var filteredOrders    = orderServiceProxy.GetOrders("C100011");

            foreach (var order in filteredOrders)
            {
                Console.WriteLine(order.ToString());
            }
            Console.WriteLine();
            Console.WriteLine("End of App!");
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            using (var customerServiceProxy = new CustomerServiceProxy())
            {
                var filteredCustomer = customerServiceProxy.GetCustomerByName("wind");

                foreach (var item in filteredCustomer)
                {
                    Console.WriteLine(item.ToString());
                }

                Console.ReadLine();
            }

            using (var orderServiceProxy = new OrderServiceProxy())
            {
                var filteredOrder = orderServiceProxy.GetOrdersByCustomerId(2);
                foreach (var item in filteredOrder)
                {
                    Console.WriteLine(item.ToString());
                }
                Console.ReadLine();
            }
        }