public async Task Should_be_Able_to_Add_Document_for_Index()
        {
            var updateStatus = await index.AddDocuments(new[] { new Movie {
                                                                    Id = "1", Name = "Batman"
                                                                } });

            updateStatus.UpdateId.Should().BeGreaterOrEqualTo(0);
        }
Esempio n. 2
0
        public async Task Basic_Version_Of_default_client()
        {
            MeilisearchClient ms = new MeilisearchClient("http://localhost:7700", "masterKey");
            var   indexName      = "uid" + new Random().Next();
            Index index          = await ms.CreateIndex(indexName);

            var updateStatus = await index.AddDocuments(new[] { new  Movie {
                                                                    Id = "1", Name = "Batman"
                                                                } });

            updateStatus.UpdateId.Should().BeGreaterOrEqualTo(0);
        }
        public async Task BasicDocumentsAddition()
        {
            var   indexUID = "BasicDocumentsAdditionTest";
            Index index    = await this.client.GetOrCreateIndex(indexUID);

            // Add the documents
            UpdateStatus update = await index.AddDocuments(new[] { new Movie {
                                                                       Id = "1", Name = "Batman"
                                                                   } });

            update.UpdateId.Should().BeGreaterOrEqualTo(0);
            await index.WaitForPendingUpdate(update.UpdateId);

            // Check the documents have been added
            var docs = await index.GetDocuments <Movie>();

            Assert.Equal("1", docs.First().Id);
            Assert.Equal("Batman", docs.First().Name);
            docs.First().Genre.Should().BeNull();
        }
        public async Task BasicDocumentsUpdate()
        {
            var   indexUID = "BasicDocumentsUpdateTest";
            Index index    = await this.client.GetOrCreateIndex(indexUID);

            // Add the documents
            UpdateStatus update = await index.AddDocuments(new[]
            {
                new Movie {
                    Id = "1", Name = "Batman", Genre = "Action"
                },
                new Movie {
                    Id = "2", Name = "Superman"
                },
            });

            update.UpdateId.Should().BeGreaterOrEqualTo(0);
            await index.WaitForPendingUpdate(update.UpdateId);

            // Update the documents
            update = await index.UpdateDocuments(new[] { new Movie {
                                                             Id = "1", Name = "Ironman"
                                                         } });

            update.UpdateId.Should().BeGreaterOrEqualTo(0);
            await index.WaitForPendingUpdate(update.UpdateId);

            // Check the documents have been updated and added
            var docs = await index.GetDocuments <Movie>();

            Assert.Equal("1", docs.First().Id);
            Assert.Equal("Ironman", docs.First().Name);

            // Assert.Equal("Action", docs.First().Genre); // Commented until the issue #67 is fixed (https://github.com/meilisearch/meilisearch-dotnet/issues/67)
            Assert.Equal("2", docs.ElementAt(1).Id);
            Assert.Equal("Superman", docs.ElementAt(1).Name);
            docs.ElementAt(1).Genre.Should().BeNull();
        }