Example #1
0
        private IndexBatch <Hotel> GetTypedRetryBatch()
        {
            IEnumerable <string> allKeys = _results.Results.Select(r => r.Key);

            var exception = new IndexBatchException(_results);
            IndexBatch <Hotel> originalBatch = IndexBatch.Upload(allKeys.Select(k => new Hotel()
            {
                HotelId = k
            }));

            return(exception.FindFailedActionsToRetry(originalBatch, h => h.HotelId));
        }
Example #2
0
        private IndexBatch GetRetryBatch()
        {
            IEnumerable <string> allKeys = _results.Results.Select(r => r.Key);

            var        exception     = new IndexBatchException(_results);
            IndexBatch originalBatch = IndexBatch.Upload(allKeys.Select(k => new Document()
            {
                { KeyFieldName, k }
            }));

            return(exception.FindFailedActionsToRetry(originalBatch, KeyFieldName));
        }
Example #3
0
        private static void AssertIsPartialFailure(
            IndexBatchException e,
            IndexBatch <Hotel> batch,
            params string[] failedKeys)
        {
            Assert.Equal((HttpStatusCode)207, e.Response.StatusCode);
            Assert.Equal((HttpStatusCode)207, e.IndexResponse.StatusCode);

            IndexBatch <Hotel> retryBatch = e.FindFailedActionsToRetry(batch, a => a.HotelId);

            Assert.Equal(failedKeys.Length, retryBatch.Actions.Count());
            SearchAssert.SequenceEqual(failedKeys, retryBatch.Actions.Select(a => a.Document.HotelId));
        }
Example #4
0
        private static void AssertIsPartialFailure(
            IndexBatchException e,
            IndexBatch batch,
            params string[] failedKeys)
        {
            Assert.Equal((HttpStatusCode)207, e.Response.StatusCode);
            Assert.Equal((HttpStatusCode)207, e.IndexResponse.StatusCode);

            const string KeyFieldName = "hotelId";
            IndexBatch   retryBatch   = e.FindFailedActionsToRetry(batch, KeyFieldName);

            Assert.Equal(failedKeys.Length, retryBatch.Actions.Count());
            SearchAssert.SequenceEqual(failedKeys, retryBatch.Actions.Select(a => a.Document[KeyFieldName].ToString()));
        }