public void ValidatingRuleSetReturnsValidationResults() { var mappingManager = new MappingManager(); var mappingValidationManager = new MappingValidator(mappingManager, new[] {new DummyValidationRuleError()}); var validationResults = mappingValidationManager.EnumerateValidationResults(typeof(SchemaMappingTestDocument), new SolrSchema()).ToList(); Assert.AreEqual(1, validationResults.Count); }
public void MultivaluedSolrFieldMappedToCollectionShouldNotReturnError() { var mgr = new MappingManager(); mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("NameCollection"), "name"); var schemaManager = new MappingValidator(mgr, new[] {new MultivaluedMappedToCollectionRule()}); var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaMultiValuedName.xml"); var solrSchemaParser = new SolrSchemaParser(); var schema = solrSchemaParser.Parse(schemaXmlDocument); var validationResults = schemaManager.EnumerateValidationResults(typeof (SchemaMappingTestDocument), schema).ToList(); Assert.AreEqual(0, validationResults.Count); }
public void StringMappedToStringShouldNotReturnError() { var mappingTypesCompatibleRule = new MappingTypesAreCompatibleWithSolrTypesRule(new[] {new StringSolrFieldTypeChecker()}); var mgr = new MappingManager(); var schemaManager = new MappingValidator(mgr, new[] {mappingTypesCompatibleRule}); var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaMappingTypes.xml"); var solrSchemaParser = new SolrSchemaParser(); var schema = solrSchemaParser.Parse(schemaXmlDocument); var validationResults = schemaManager.EnumerateValidationResults(typeof (SchemaMappingTestDocument), schema).ToList(); Assert.AreEqual(0, validationResults.Count); }
public void MatchingUniqueKeyMappingShouldNotReturnError() { var mgr = new MappingManager(); mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("ID"), "id"); mgr.SetUniqueKey(typeof (SchemaMappingTestDocument).GetProperty("ID")); var schemaManager = new MappingValidator(mgr, new[] {new UniqueKeyMatchesMappingRule()}); var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); var solrSchemaParser = new SolrSchemaParser(); var schema = solrSchemaParser.Parse(schemaXmlDocument); var validationResults = schemaManager.EnumerateValidationResults(typeof (SchemaMappingTestDocument), schema).ToList(); Assert.AreEqual(0, validationResults.Count); }
public void RequiredSolrFieldForWhichNoCopyFieldExistsShouldReturnError() { var mgr = new MappingManager(); mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("ID"), "id"); mgr.SetUniqueKey(typeof (SchemaMappingTestDocument).GetProperty("ID")); var schemaManager = new MappingValidator(mgr, new[] {new RequiredFieldsAreMappedRule()}); var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); var solrSchemaParser = new SolrSchemaParser(); var schema = solrSchemaParser.Parse(schemaXmlDocument); var validationResults = schemaManager.EnumerateValidationResults(typeof (SchemaMappingTestDocument), schema).ToList(); Assert.AreEqual(1, validationResults.Count); }
public void MappedPropertyForWhichDynamicFieldExistsInSchemaShouldNotReturnError() { var mgr = new MappingManager(); mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("ID"), "id"); mgr.SetUniqueKey(typeof (SchemaMappingTestDocument).GetProperty("ID")); mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("Name"), "name"); mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("Producer"), "producer_s"); var schemaManager = new MappingValidator(mgr, new[] {new MappedPropertiesIsInSolrSchemaRule()}); var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); var solrSchemaParser = new SolrSchemaParser(); var schema = solrSchemaParser.Parse(schemaXmlDocument); var validationResults = schemaManager.EnumerateValidationResults(typeof (SchemaMappingTestDocument), schema).ToList(); Assert.AreEqual(0, validationResults.Count); }