コード例 #1
0
        public void TestDeleteObjectsObjectId()
        {
            ClearTest();
            _indexHelper = new IndexHelper <TestModel>(_client, GetSafeName("àlgol?à-csharp"), "TestModelId");

            var model = BuildTestModel();
            var task  = _indexHelper.SaveObject(model);

            _indexHelper.WaitTask(task["taskID"].ToString());

            var models = BuildTestModelList();
            var tasks  = _indexHelper.SaveObjects(models);

            foreach (var item in tasks)
            {
                _indexHelper.WaitTask(item["taskID"].ToString());
            }

            var res = _indexHelper.Search(new Query(""));

            Assert.Equal(5, res["nbHits"].ToObject <int>());
            Assert.Equal("Sylvain", res["hits"][0]["FirstName"].ToString());
            Assert.Equal("8", res["hits"][0]["objectID"].ToString());

            tasks = _indexHelper.DeleteObjects(models);
            foreach (var item in tasks)
            {
                _indexHelper.WaitTask(item["taskID"].ToString());
            }

            res = _indexHelper.Search(new Query(""));

            Assert.Equal(1, res["nbHits"].ToObject <int>());
            Assert.Equal("Scott", res["hits"][0]["FirstName"].ToString());
            Assert.Equal("10", res["hits"][0]["objectID"].ToString());
        }
コード例 #2
0
        public void TestDeleteObjectsObjectId()
        {
            ClearTest();
            _indexHelper = new IndexHelper<TestModel>(_client, GetSafeName("àlgol?à-csharp"), "TestModelId");

            var model = BuildTestModel();
            var task = _indexHelper.SaveObject(model);
            _indexHelper.WaitTask(task["taskID"].ToString());

            var models = BuildTestModelList();
            var tasks = _indexHelper.SaveObjects(models);
            foreach (var item in tasks)
            {
                _indexHelper.WaitTask(item["taskID"].ToString());
            }

            var res = _indexHelper.Search(new Query(""));

            Assert.AreEqual(5, res["nbHits"].ToObject<int>());
            Assert.AreEqual("Sylvain", res["hits"][0]["FirstName"].ToString());
            Assert.AreEqual("8", res["hits"][0]["objectID"].ToString());

            tasks = _indexHelper.DeleteObjects(models);
            foreach (var item in tasks)
            {
                _indexHelper.WaitTask(item["taskID"].ToString());
            }

            res = _indexHelper.Search(new Query(""));

            Assert.AreEqual(1, res["nbHits"].ToObject<int>());
            Assert.AreEqual("Scott", res["hits"][0]["FirstName"].ToString());
            Assert.AreEqual("10", res["hits"][0]["objectID"].ToString());
        }