コード例 #1
0
        protected override void ExpectResponse(IGetFieldMappingResponse response)
        {
            response.Indices.Should()
            .NotBeEmpty("expect indices on the response")
            .And.ContainKey(Index <Project>(), "expect project to return field mappings")
            .And.ContainKey(Index <ProjectPercolation>(), "expect project percolation to return field mappings");

            var projectMappings = response.Indices[Index <Project>()];

            projectMappings.Should().NotBeNull("project mapping value in the dictionary should not point to a null value");
            projectMappings.Mappings.Should()
            .NotBeEmpty("project has fields so should contain a type mapping")
            .And.ContainKey(Type <Project>(), "the inferred type for project should be found in the index mapping");

            var projectTypeMappings = projectMappings.Mappings[Type <Project>()];

            projectTypeMappings.Should().NotBeNull("project type mapping value should not point to a null value");

            projectTypeMappings.Should()
            .NotBeEmpty("project mappings should return fields")
            .And.HaveCount(2, "project mapping should return both fields")
            .And.ContainKey(NameField, "name is a field in the project index");

            var fieldTypeMapping = projectTypeMappings[NameField];

            fieldTypeMapping.Should().NotBeNull("name field mapping should exist");
            fieldTypeMapping.FullName.Should().NotBeNullOrEmpty();
            fieldTypeMapping.Mapping.Should()
            .NotBeEmpty("field type mapping should return a `mapping` with the field information")
            .And.HaveCount(1, "field type mappings only return information from a single field")
            .And.ContainKey(NameField);

            var fieldMapping = fieldTypeMapping.Mapping[NameField];

            AssertNameFieldMapping(fieldMapping);

            fieldMapping = response.MappingFor <Project>(NameField);
            AssertNameFieldMapping(fieldMapping);

            fieldMapping = response.MappingFor <Project>(p => p.Name);
            AssertNameFieldMapping(fieldMapping);
        }
コード例 #2
0
        protected override void ExpectResponse(IGetFieldMappingResponse response)
        {
            var fieldMapping = response.MappingFor <Project>("name");

            fieldMapping.Should().NotBeNull();
        }