Ejemplo n.º 1
0
        public void TestSetup()
        {
            var es            = new ESImpl(ESUri);
            var clusterHealth = es.ClusterHealth();

            Console.WriteLine(clusterHealth);
            Assert.IsTrue(clusterHealth.IsValid);
        }
Ejemplo n.º 2
0
        public async Task TestIndexCreation()
        {
            var es = new ESImpl(ESUri);
            var initialClusterHealth = es.GetIndex("blog_post");

            Assert.IsTrue(initialClusterHealth == null || initialClusterHealth.Count() == 0, "Initial cluster health is invalid");
            var createResult = es.CreateIndex("blog_post");

            Assert.IsTrue(createResult, "Index wasn't created");
            var finalClusterHealth = es.GetIndex("blog_post");
            await Task.Delay(1000);

            Assert.IsTrue(finalClusterHealth != null && finalClusterHealth.Count() == 1, "Final cluster health is invalid");
            var deleteResult = es.DeleteIndex("blog_post");

            Assert.IsTrue(deleteResult, "Delete didn't work");
        }
Ejemplo n.º 3
0
        public async Task TestPostAndSearchMessage()
        {
            var es           = new ESImpl(ESUri);
            var createResult = es.CreateIndex("blog_post");

            Assert.IsTrue(createResult, "Index wasn't created");
            var searchResults = es.SearchAllDocuments();
            var postResult    = es.PostDocuments(new Post()
            {
                UserId   = 1,
                PostDate = DateTime.UtcNow,
                PostText = "This is an awesome post"
            });

            Assert.IsTrue(postResult);
            await Task.Delay(1000);

            searchResults = es.SearchAllDocuments();
            Assert.IsTrue(searchResults != null && searchResults.Count() == 1, "Search failed");
            var deleteResult = es.DeleteIndex("blog_post");

            Assert.IsTrue(deleteResult, "Delete didn't work");
        }