Beispiel #1
0
        public void WhenQuerying_ThenPopulatesMatchingEntities()
        {
            using (var ws = new HttpWebService <HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
            {
                var client   = new HttpEntityConventionClient(ws.BaseUri);
                var ids      = client.Query <Product>().Where(x => x.Owner.Name == "kzu").Select(x => x.Id).ToList();
                var products = client.Query <Product>().Where(x => x.Owner.Name == "kzu").ToList();

                Assert.Equal(2, ids.Count);
                Assert.True(products.All(x => x.Owner.Name == "kzu"));
            }
        }
Beispiel #2
0
        public void WhenQueryingWithExtraCriteria_ThenPopulatesMatchingEntities()
        {
            using (var ws = new HttpWebService <HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
            {
                var client   = new HttpEntityConventionClient(ws.BaseUri);
                var products = client.Query <Product>(new { search = "kzu" }).ToList();

                Assert.True(products.All(x => x.Owner.Name == "kzu"));
            }
        }
Beispiel #3
0
        public void WhenQueryingAndNoMatches_ThenReturnsEmptyEnumerable()
        {
            using (var ws = new HttpWebService <HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
            {
                var client   = new HttpEntityConventionClient(ws.BaseUri);
                var products = client.Query <Product>().Where(x => x.Owner.Name == "foo").ToList();

                Assert.Equal(0, products.Count);
            }
        }
Beispiel #4
0
        public void WhenSkipTakeOnly_ThenReturnsSingleElement()
        {
            using (var ws = new HttpWebService <HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
            {
                var client   = new HttpEntityConventionClient(ws.BaseUri);
                var products = client.Query <Product>().Skip(1).Take(1).ToList();

                Assert.Equal(1, products.Count);
                Assert.Equal(2, products[0].Id);
            }
        }
Beispiel #5
0
        public void WhenOrderByTake_ThenReturnsOrdered()
        {
            using (var ws = new HttpWebService <HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
            {
                var client   = new HttpEntityConventionClient(ws.BaseUri);
                var products = client.Query <Product>().OrderBy(x => x.Title).Take(2).ToList();

                Assert.Equal(2, products.Count);
                Assert.Equal("A", products[0].Title);
                Assert.Equal("B", products[1].Title);
            }
        }
Beispiel #6
0
        public void WhenQueryingWithExtraCriteria_ThenGetsTotalCount()
        {
            using (new SafeHostDisposer(
                       new HttpQueryableServiceHost(typeof(HttpEntityConventionClientTestService),
                                                    25, new ServiceConfiguration(),
                                                    new Uri("http://localhost:20000/products"))))
            {
                var client = new HttpEntityConventionClient("http://localhost:20000");
                var query  = (IHttpEntityQuery <Product>)client.Query <Product>(new { search = "kzu" }).Take(1);

                var result = query.Execute();

                Assert.Equal(2, result.TotalCount);
                Assert.Equal(1, result.Count());
            }
        }
		public void WhenQueryingWithExtraCriteria_ThenGetsTotalCount()
		{
			using (new SafeHostDisposer(
				new HttpQueryableServiceHost(typeof(HttpEntityConventionClientTestService),
					25, new ServiceConfiguration(),
					new Uri("http://localhost:20000/products"))))
			{
				var client = new HttpEntityConventionClient("http://localhost:20000");
				var query = (IHttpEntityQuery<Product>)client.Query<Product>(new { search = "kzu" }).Take(1);

				var result = query.Execute();

				Assert.Equal(2, result.TotalCount);
				Assert.Equal(1, result.Count());
			}
		}
		public void WhenQueryingWithExtraCriteria_ThenPopulatesMatchingEntities()
		{
			using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
			{
				var client = new HttpEntityConventionClient(ws.BaseUri);
				var products = client.Query<Product>(new { search = "kzu" }).ToList();

				Assert.True(products.All(x => x.Owner.Name == "kzu"));
			}
		}
		public void WhenOrderByTake_ThenReturnsOrdered()
		{
			using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
			{
				var client = new HttpEntityConventionClient(ws.BaseUri);
				var products = client.Query<Product>().OrderBy(x => x.Title).Take(2).ToList();

				Assert.Equal(2, products.Count);
				Assert.Equal("A", products[0].Title);
				Assert.Equal("B", products[1].Title);
			}
		}
		public void WhenSkipTakeOnly_ThenReturnsSingleElement()
		{
			using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
			{
				var client = new HttpEntityConventionClient(ws.BaseUri);
				var products = client.Query<Product>().Skip(1).Take(1).ToList();

				Assert.Equal(1, products.Count);
				Assert.Equal(2, products[0].Id);
			}
		}
		public void WhenQueryingAndNoMatches_ThenReturnsEmptyEnumerable()
		{
			using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
			{
				var client = new HttpEntityConventionClient(ws.BaseUri);
				var products = client.Query<Product>().Where(x => x.Owner.Name == "foo").ToList();

				Assert.Equal(0, products.Count);
			}
		}
		public void WhenQuerying_ThenPopulatesMatchingEntities()
		{
			using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
			{
				var client = new HttpEntityConventionClient(ws.BaseUri);
				var ids = client.Query<Product>().Where(x => x.Owner.Name == "kzu").Select(x => x.Id).ToList();
				var products = client.Query<Product>().Where(x => x.Owner.Name == "kzu").ToList();

				Assert.Equal(2, ids.Count);
				Assert.True(products.All(x => x.Owner.Name == "kzu"));
			}
		}