public void Should_map_lookup_to_getByExample() { foreach (var m in _mappings.OrderBy(x => x.SourceName)) { var xmlModels = new List <ModelMetadata>(); MetadataMappingFactoryBase.PopulateModelMetadata(_xmlMetadata, xmlModels, m.SourceName); var unmappedXmlProperties = xmlModels .Where(xm => xm.IsSimpleType && m.Properties.All(p => p.SourceName != xm.PropertyPath)).ToList(); var jsonModels = new List <ModelMetadata>(); MetadataMappingFactoryBase.PopulateModelMetadata(_jsonMetadata, jsonModels, m.TargetName); var unmappedJsonProperties = jsonModels .Where(jm => jm.IsSimpleType && m.Properties.All(p => p.TargetName != jm.PropertyPath)).ToList(); // Uncomment to only see resources with missing mappings //if (!unmappedXmlProperties.Any() && !unmappedJsonProperties.Any()) // continue; Console.WriteLine($"{m.SourceName}, {m.TargetName}"); //Console.WriteLine(JsonConvert.SerializeObject(m)); foreach (var p in m.Properties.OrderBy(x => x.SourceName)) { Console.WriteLine( p.IsArray ? $"\t{p.SourceName} ({p.SourceType}[]), {p.TargetName} ({p.TargetType}[])\t{p.MappingStrategy.GetType().Name}" : $"\t{p.SourceName} ({p.SourceType}), {p.TargetName} ({p.TargetType})\t{p.MappingStrategy.GetType().Name}"); } if (unmappedXmlProperties.Any()) { Console.WriteLine("\tUnmapped Xml Properties:"); foreach (var unmappedProperty in unmappedXmlProperties /*.Select(up => up.PropertyPath).Distinct()*/ ) { Console.WriteLine( $"\t\t{unmappedProperty.PropertyPath} ({unmappedProperty.Type}, {unmappedProperty.IsRequired})"); } } if (unmappedJsonProperties.Any()) { Console.WriteLine("\tUnmapped Json Properties:"); foreach (var unmappedProperty in unmappedJsonProperties /*.Select(up => up.PropertyPath).Distinct()*/) { Console.WriteLine( $"\t\t{unmappedProperty.PropertyPath} ({unmappedProperty.Type}, {unmappedProperty.IsRequired})"); } } Console.WriteLine(); } }
public void Should_map_resource_to_identity() { foreach (var mapping in _mappings.OrderBy(x => x.SourceName)) { var sourceModels = new List <ModelMetadata>(); MetadataMappingFactoryBase.PopulateModelMetadata(_xmlMetadata, sourceModels, mapping.SourceName); var targetModels = new List <ModelMetadata>(); MetadataMappingFactoryBase.PopulateModelMetadata(_jsonMetadata, targetModels, mapping.TargetName); //var unmappedSourceProperties = // sourceModels.Where( // m => m.IsSimpleType && mapping.Properties.All(p => p.SourceName != m.PropertyPath)) // .ToList(); //var unmappedTargetProperties = // targetModels.Where( // m => m.IsSimpleType && mapping.Properties.All(p => p.TargetName != m.PropertyPath)) // .ToList(); // Uncomment to only see resources with missing mappings //if (!unmappedXmlProperties.Any() && !unmappedJsonProperties.Any()) // continue; Console.WriteLine($"{mapping.SourceName}, {mapping.TargetName}"); foreach (var p in mapping.Properties.OrderBy(x => x.SourceName)) { Console.WriteLine( p.IsArray ? $"\t{p.SourceName} ({p.SourceType}[]), {p.TargetName} ({p.TargetType}[])\t{p.MappingStrategy.GetType().Name}" : $"\t{p.SourceName} ({p.SourceType}), {p.TargetName} ({p.TargetType})\t{p.MappingStrategy.GetType().Name}"); } //if (unmappedSourceProperties.Any()) //{ // Console.WriteLine($"\tUnmapped Source Properties:"); // foreach (var unmappedProperty in unmappedSourceProperties // /*.Select(up => up.PropertyPath).Distinct()*/) // { // Console.WriteLine( // $"\t\t{unmappedProperty.PropertyPath} ({unmappedProperty.Type}, {unmappedProperty.IsRequired})"); // } //} //if (unmappedTargetProperties.Any()) //{ // Console.WriteLine($"\tUnmapped Target Properties:"); // foreach (var unmappedProperty in unmappedTargetProperties // /*.Select(up => up.PropertyPath).Distinct()*/) // { // Console.WriteLine( // $"\t\t{unmappedProperty.PropertyPath} ({unmappedProperty.Type}, {unmappedProperty.IsRequired})"); // } //} Console.WriteLine(); } }