Ejemplo n.º 1
0
        public async Task Should_Throw_an_Exception_if_the_Index_Is_already_Taken()
        {
            var httpclient = ClientFactory.Instance.CreateClient <MeilisearchClient>();
            var client     = new MeilisearchClient(httpclient);
            var indexName  = "uid3" + new Random().Next();
            var index      = await client.CreateIndex(indexName, "movieId");

            await Assert.ThrowsAsync <Exception>(() => client.CreateIndex(indexName, "movieId"));
        }
Ejemplo n.º 2
0
 private void SetUpForDelete()
 {
     try
     {
         var client = new MeilisearchClient(_httpClient);
         var index  = client.GetIndex("MoviesToDelete").Result;
         if (index == null)
         {
             this.DocumentDeleteIndex = client.CreateIndex("MoviesToDelete").Result;
         }
         else
         {
             this.DocumentDeleteIndex = index;
         }
         var movies = new[]
         {
             new Movie {
                 Id = "10", Name = "SuperMan"
             },
         };
         var updateStatus = this.DocumentDeleteIndex.AddorUpdateDocuments(movies).Result;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Ejemplo n.º 3
0
        public async Task Should_be_able_To_Create_Index()
        {
            var _httpClient = ClientFactory.Instance.CreateClient <MeilisearchClient>();
            var client      = new MeilisearchClient(_httpClient);
            var indexName   = "uid" + new Random().Next();
            var index       = await client.CreateIndex(indexName);

            index.Uid.Should().Be(indexName);
        }
Ejemplo n.º 4
0
        public async Task Should_be_able_To_Create_Index_with_primaryKey()
        {
            var httpclient = ClientFactory.Instance.CreateClient <MeilisearchClient>();
            var client     = new MeilisearchClient(httpclient);
            var indexName  = "uid2" + new Random().Next();
            var index      = await client.CreateIndex(indexName, "movieId");

            index.Uid.Should().Be(indexName);
            index.PrimaryKey.Should().Be("movieId");
        }
Ejemplo n.º 5
0
        public async Task Should_return_All_The_Index_In_the_System()
        {
            var _httpClient = ClientFactory.Instance.CreateClient <MeilisearchClient>();
            var client      = new MeilisearchClient(_httpClient);
            var indexName   = "uid4" + new Random().Next();
            var index       = await client.CreateIndex(indexName, "movieId");

            var indexes = await client.GetAllIndexes();

            indexes.Count().Should().BeGreaterOrEqualTo(1);
        }
Ejemplo n.º 6
0
        public async Task Should_return_the_index_requested()
        {
            var _httpClient = ClientFactory.Instance.CreateClient <MeilisearchClient>();
            var client      = new MeilisearchClient(_httpClient);
            var indexName   = "uid5" + new Random().Next();
            var index       = await client.CreateIndex(indexName, "movieId");

            var indexes = await client.GetIndex(indexName);

            index.Uid.Should().Be(indexName);
        }
Ejemplo n.º 7
0
        public async Task Should_be_Able_To_Modify_Primary_Key()
        {
            var httpclient = ClientFactory.Instance.CreateClient <MeilisearchClient>();
            var client     = new MeilisearchClient(httpclient);
            var index      = await client.CreateIndex("Indextest" + new Random().Next());

            var primarykey    = "MovieId" + new Random().Next();
            var modifiedIndex = await index.ChangePrimaryKey(primarykey);

            modifiedIndex.PrimaryKey.Should().Be(primarykey);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        public async Task BasicUsageOfCustomClient()
        {
            var httpClient       = ClientFactory.Instance.CreateClient <MeilisearchClient>();
            MeilisearchClient ms = new MeilisearchClient(httpClient);
            var indexUid         = "uid" + new Random().Next();

            Meilisearch.Index index = await ms.CreateIndex(indexUid);

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

            updateStatus.UpdateId.Should().BeGreaterOrEqualTo(0);
        }
Ejemplo n.º 10
0
        public async Task Should_be_Able_to_Get_Status_By_Id()
        {
            var httpclient = ClientFactory.Instance.CreateClient <MeilisearchClient>();
            var client     = new MeilisearchClient(httpclient);
            var indexName  = "MoviesStatus" + new Random().Next();
            var index      = await client.CreateIndex(indexName);

            var status = await index.AddorUpdateDocuments(new[] { new Movie {
                                                                      Id = "2"
                                                                  } });

            UpdateStatus individualStatus = await index.GetUpdateStatus(status.UpdateId);

            individualStatus.Should().NotBeNull();
        }
Ejemplo n.º 11
0
        public async Task Should_be_Able_to_get_All_The_Update_Status()
        {
            var httpclient = ClientFactory.Instance.CreateClient <MeilisearchClient>();
            var client     = new MeilisearchClient(httpclient);
            var indexName  = "MoviesStatus" + new Random().Next();
            var index      = await client.CreateIndex(indexName);

            await index.AddorUpdateDocuments(new[] { new Movie {
                                                         Id = "1"
                                                     } });

            var status = await index.GetAllUpdateStatus();

            status.Count().Should().BeGreaterOrEqualTo(1);
        }
Ejemplo n.º 12
0
        public void SetUp()
        {
            try
            {
                var client = new MeilisearchClient(_httpClient);
                var index  = client.GetIndex("Movies").Result;

                if (index == null)
                {
                    this.documentIndex = client.CreateIndex("Movies").Result;
                }
                else
                {
                    this.documentIndex = index;
                }

                var movies = new[]
                {
                    new Movie {
                        Id = "10", Name = "SuperMan"
                    },
                    new Movie {
                        Id = "11", Name = "SpiderMan"
                    },
                    new Movie {
                        Id = "12", Name = "IronMan"
                    },
                    new Movie {
                        Id = "13", Name = "SpiderMan"
                    },
                    new Movie {
                        Id = "14", Name = "IronMan"
                    },
                    new Movie {
                        Id = "15", Name = "SpiderMan"
                    },
                    new Movie {
                        Id = "16", Name = "IronMan"
                    }
                };
                var updateStatus = this.documentIndex.AddorUpdateDocuments(movies).Result;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 13
0
 public async Task Should_Fail_to_Create_If_the_Index_is_of_bad_Format()
 {
     var httpclient = ClientFactory.Instance.CreateClient <MeilisearchClient>();
     var client     = new MeilisearchClient(httpclient);
     await Assert.ThrowsAsync <Exception>(() => client.CreateIndex("wrong UID"));
 }