Beispiel #1
0
        public ViewsFixture()
        {
            Artists = TestData.Artists.CreateArtists(10);

            _client = IntegrationTestsRuntime.CreateClient();

            var bulk = new BulkCommand();
            bulk.Include(Artists.Select(i => _client.Entities.Serializer.Serialize(i)).ToArray());

            var bulkResponse = _client.Documents.BulkAsync(bulk);

            foreach (var row in bulkResponse.Result.Rows)
            {
                var artist = Artists.Single(i => i.ArtistId == row.Id);
                _client.Entities.Reflector.RevMember.SetValueTo(artist, row.Rev);
            }

            _client.Documents.PostAsync(TestData.Views.Artists).Wait();

            var touchView1 = new ViewQuery(TestData.Views.ArtistsAlbumsViewId).Configure(q => q.Stale(Stale.UpdateAfter));
            var touchView2 = new ViewQuery(TestData.Views.ArtistsNameNoValueViewId).Configure(q => q.Stale(Stale.UpdateAfter));

            _client.Views.RunQueryAsync(touchView1).Wait();
            _client.Views.RunQueryAsync(touchView2).Wait();
        }
Beispiel #2
0
        internal static void ClearAllDocuments(this IClient client)
        {
            var query = new SystemViewQuery("_all_docs");
            var response = client.Views.RunQueryAsync<dynamic>(query).Result;

            if (!response.IsEmpty)
            {
                var bulkCmd = new BulkCommand();

                foreach (var row in response.Rows)
                    bulkCmd.Delete(row.Id, row.Value.rev.ToString());
                
                client.Documents.BulkAsync(bulkCmd).Wait();
            }
        }