public void AsynchronousExecution()
        {
            HttpClient client = new HttpClient(address);
            var customers = client.CreateQuery<Customer>("Customers");

            // EndX method
            customers.ExecuteAsync().ContinueWith(t => Assert.AreEqual(5, t.Result.Count()));

            var q =
                from customer in customers
                where customer.Id > 4
                select customer;

            customers = ((WebQuery<Customer>)q);
            // Callback
            customers.ExecuteAsync().ContinueWith(t=>Callback(t.Result));
            mre.WaitOne();
        }
        public void Basic()
        {
            foreach (var baseAddress in baseAddresses)
            {
                HttpClient client = new HttpClient(baseAddress);
                client.Channel = new WebRequestChannel();

                HttpClient client2 = new HttpClient(new Uri(baseAddress));
                client2.Channel = new WebRequestChannel();

                foreach (var relativeAddress in resourceAddresses)
                {
                    WebQuery<Customer> q = client.CreateQuery<Customer>(relativeAddress);
                    WebQuery<Customer> q2 = client2.CreateQuery<Customer>(new Uri(relativeAddress, UriKind.Relative));
                    string s = q.RequestUri.AbsoluteUri;
                    string s2 = q2.RequestUri.AbsoluteUri;

                    Assert.AreEqual(s, s2);
                }
            }
        }
        public void NestedQueryTest()
        {
            HttpClient client = new HttpClient(address);
            var customers = client.CreateQuery<Customer>("Customers");

            var customersNested = (WebQuery<Customer>)
                customers.Where(customer => customer.Id > customers.Skip(2).First().Id);

            Assert.AreEqual(2, customersNested.ToList().Count());
        }
 public void TestMockFailedComposer2()
 {
     HttpClient client = new HttpClient(address2);
     var customers = client.CreateQuery<Customer>("Failed");
     customers.Execute();
 }
        public void SynchronousExecution2()
        {
            HttpClient client = new HttpClient(address2);
            var customers = client.CreateQuery<Customer>("Customers");
            Console.WriteLine("All customers using XML deserialization");
            PrintCustomers(customers);
            Assert.AreEqual(5, customers.ToList().Count());

            var customersJson = client.CreateQuery<Customer>("CustomersJson");
            Console.WriteLine("All customers using JSON deserialization");
            PrintCustomers(customersJson);
            Assert.AreEqual(5, customers.ToList().Count());

            var customersWildcard = client.CreateQuery<Customer>("");
            Console.WriteLine("Customers returned by wildcard method");
            PrintCustomers(customersWildcard);
            Assert.AreEqual(5, customers.ToList().Count());

            Console.WriteLine("All customers whose id > 4");
            var q =
                from customer in customers
                where customer.Id > 4
                select customer;
            Assert.AreEqual(1, q.ToList().Count());
            Assert.AreEqual(1, q.ToList().Count());

            var results = ((WebQuery<Customer>)q).Execute();
            Assert.AreEqual(1, results.ToList().Count());

            var customersNone = client.CreateQuery<Customer>("CustomersNone");
            Assert.AreEqual(1, results.ToList().Count());
        }
        public void SingleElementOperations2()
        {
            HttpClient client = new HttpClient(address2);
            var customers = client.CreateQuery<Customer>("Customers");

            Assert.AreEqual("LastName1", customers.First().Name);
            Assert.AreEqual("LastName1", customers.Take(1).Single().Name);
        }
 public void EmptyQuery()
 {
     HttpClient client = new HttpClient(baseAddresses[0]);
     WebQuery<Customer> emptyQuery = client.CreateQuery<Customer>();
     Console.WriteLine("Empty query resource at: {0}", emptyQuery.RequestUri.AbsoluteUri);
 }