public List <MappingValidatorType> Validate(IndexInformation index) { var errors = new List <MappingValidatorType>(); IndexMapping currentMappings = GetCurrentIndexMappings(index); List <(Type, List <IndexableProperty>)> correctMappings = GetCorrectMappings(index); foreach ((Type, List <IndexableProperty>)correctMapping in correctMappings) { var properties = new List <MappingValidatorProperty>(); foreach (IndexableProperty indexableProperty in correctMapping.Item2) { CoreIndexer.GetPropertyMapping(indexableProperty, "no", currentMappings, out MappingConflict mappingConflict); if (mappingConflict != MappingConflict.Found) { IEnumerable <string> errorDescriptions = mappingConflict.AsEnumDescriptions(); properties.Add(new MappingValidatorProperty(indexableProperty.Name, errors: errorDescriptions)); } } if (properties.Any()) { errors.Add(new MappingValidatorType(correctMapping.Item1.Name, properties)); } } return(errors); }
public CoreIndexerTests(ServiceLocatorFixture fixture) { _fixture = fixture; _fixture.ServiceLocationMock.SettingsMock .Setup(m => m.GetDefaultIndexName("de")) .Returns("my-index"); _fixture.ServiceLocationMock.SettingsMock .Setup(m => m.GetDefaultIndexName("sv")) .Returns("delete-me"); _fixture.ServiceLocationMock.HttpClientMock .Setup(m => m.Head(new Uri("http://example.com/bad-index"))) .Returns(HttpStatusCode.NotFound); _fixture.ServiceLocationMock.HttpClientMock .Setup(m => m.Head(new Uri("http://example.com/my-index"))) .Returns(HttpStatusCode.OK); _coreIndexer = new CoreIndexer( _fixture.ServiceLocationMock.SettingsMock.Object, _fixture.ServiceLocationMock.HttpClientMock.Object); }