Example #1
0
        public void RemoteDynamicFacetedSearchHonorsConditionalGet()
        {
            using (var store = GetDocumentStore())
            {
                CreateCameraCostIndex(store);

                InsertCameraData(store, GetCameras(1));

                var facets = GetFacets();

                var jsonFacets = JsonConvert.SerializeObject(facets);

                long?firstEtag;

                var queryUrl = store.Url.ForDatabase(store.DefaultDatabase) + "/queries/CameraCost?query=Manufacturer%253A{0}&facetStart=0&facetPageSize=&op=facets";

                var requestUrl = string.Format(queryUrl, "canon");

                Assert.Equal(HttpStatusCode.OK, ConditionalGetHelper.PerformPost(store, requestUrl, jsonFacets, null, out firstEtag));

                //second request should give 304 not modified
                Assert.Equal(HttpStatusCode.NotModified, ConditionalGetHelper.PerformPost(store, requestUrl, jsonFacets, firstEtag, out firstEtag));

                //change index etag by inserting new doc
                InsertCameraData(store, GetCameras(1));

                long?secondEtag;

                //changing the index should give 200 OK
                Assert.Equal(HttpStatusCode.OK, ConditionalGetHelper.PerformPost(store, requestUrl, jsonFacets, firstEtag, out secondEtag));

                //next request should give 304 not modified
                Assert.Equal(HttpStatusCode.NotModified, ConditionalGetHelper.PerformPost(store, requestUrl, jsonFacets, secondEtag, out secondEtag));
            }
        }
Example #2
0
        public void RemoteDynamicFacetedSearchHonorsConditionalGet()
        {
            using (var store = GetDocumentStore())
            {
                CreateCameraCostIndex(store);

                InsertCameraData(store, GetCameras(1));

                var query = new FacetQuery
                {
                    Facets = GetFacets(),
                    Query  = "FROM INDEX 'CameraCost' WHERE Manufacturer = 'canon'"
                };

                var queryAsJson = JsonConvert.SerializeObject(query);

                string firstChangeVector;

                Assert.Equal(HttpStatusCode.OK, ConditionalGetHelper.PerformPost(store, "/queries", queryAsJson, null, out firstChangeVector));

                //second request should give 304 not modified
                Assert.Equal(HttpStatusCode.NotModified, ConditionalGetHelper.PerformPost(store, "/queries", queryAsJson, firstChangeVector, out firstChangeVector));

                //change index etag by inserting new doc
                InsertCameraData(store, GetCameras(1));

                string secondChangeVector;

                //changing the index should give 200 OK
                Assert.Equal(HttpStatusCode.OK, ConditionalGetHelper.PerformPost(store, "/queries", queryAsJson, firstChangeVector, out secondChangeVector));

                //next request should give 304 not modified
                Assert.Equal(HttpStatusCode.NotModified, ConditionalGetHelper.PerformPost(store, "/queries", queryAsJson, secondChangeVector, out secondChangeVector));
            }
        }