コード例 #1
0
        public void TestDefaultContextParentWithAnArrayOfThreeChildObjectsNested()
        {
            var testSkillParentObject = new SkillParentArray
            {
                CreatedSkillParent     = DateTime.UtcNow,
                UpdatedSkillParent     = DateTime.UtcNow,
                DescriptionSkillParent = "A test entity description",
                Id = 7,
                NameSkillParent = "cool",
                SkillChildren   = new[] { _entitiesForSkillChild[0], _entitiesForSkillChild[1], _entitiesForSkillChild[2] }
            };

            using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                context.AddUpdateDocument(testSkillParentObject, testSkillParentObject.Id);

                // Save to Elasticsearch
                var ret = context.SaveChanges();
                Assert.Equal(ret.Status, HttpStatusCode.OK);

                var roundTripResult = context.GetDocument <SkillParentArray>(testSkillParentObject.Id);
                Assert.Equal(roundTripResult.DescriptionSkillParent, testSkillParentObject.DescriptionSkillParent);
                Assert.Equal(roundTripResult.SkillChildren[0].DescriptionSkillChild, testSkillParentObject.SkillChildren[0].DescriptionSkillChild);
                Assert.Equal(roundTripResult.SkillChildren[1].DescriptionSkillChild, testSkillParentObject.SkillChildren[1].DescriptionSkillChild);
                Assert.Equal(roundTripResult.SkillChildren[2].DescriptionSkillChild, testSkillParentObject.SkillChildren[2].DescriptionSkillChild);
            }
        }
コード例 #2
0
        public void TestDefaultContextParentWithNullArrayNested()
        {
            using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                var skill = new SkillParentArray
                {
                    CreatedSkillParent = DateTime.UtcNow,
                    UpdatedSkillParent = DateTime.UtcNow,
                    Id = 34,
                    NameSkillParent        = "rr",
                    DescriptionSkillParent = "ee"
                };
                context.AddUpdateDocument(skill, skill.Id);

                // Save to Elasticsearch
                var ret = context.SaveChanges();
                Assert.Equal(ret.Status, HttpStatusCode.OK);

                var roundTripResult = context.GetDocument <SkillParentArray>(skill.Id);
                Assert.Equal(roundTripResult.DescriptionSkillParent, skill.DescriptionSkillParent);
            }
        }