private void ProcessEntity(DataModel model, DataEntity entity, DataAttributeSample sample, IEnumerable <string> remainingPath) { var attributeName = remainingPath.First(); if (attributeName.StartsWith("@")) { attributeName = attributeName.Substring(1); } // If we're at the last part of the path, add the sample... if (remainingPath.Count() == 1) { var attribute = entity.FindAttribute(attributeName); if (attribute == null) { entity.OutcastSamples.Add(sample); logger.LogWarning("{Model}: Could not find attribute '{Attribute}' in {Entity} for sample path {Path}.", model.Id, attributeName, entity.Name, sample.Path); } else { attribute.Samples.Add(sample); } } else { // Not at the last part, find the attribute within this entity and recurse down... var childAttribute = entity.FindAttribute(attributeName); if (childAttribute == null) { entity.OutcastSamples.Add(sample); logger.LogWarning("{Model}: Could not find intermediate attribute '{Attribute}' in {Entity} for sample path {Path}.", model.Id, entity.Name, attributeName, sample.Path); return; } // The childAttribute should be a ref type. If not, we're in trouble. if (childAttribute.DataType.Type != PrimitiveType.Ref) { entity.OutcastSamples.Add(sample); logger.LogWarning("{Model}: Expected attribute {Entity}.{Attribute} to be type 'ref' for sample path {Path}.", model.Id, entity.Name, attributeName, sample.Path); return; } var childEntity = model.FindEntity(childAttribute.DataType.RefName); if (childEntity == null) { entity.OutcastSamples.Add(sample); logger.LogWarning("{Model}: Could not find child ref '{Name}' for {Entity}.{Attribute} when searching sample path {Path}.", model.Id, childAttribute.DataType.RefName, entity.Name, attributeName, sample.Path); return; } ProcessEntity(model, childEntity, sample, remainingPath.Skip(1)); } }
public void Equality() { // Arrange var dataAttribute = entity.FindAttribute("Name"); var mapped1 = new MappedDataAttribute { Attribute = dataAttribute }; var mapped2 = new MappedDataAttribute { Attribute = dataAttribute }; // Act and assert mapped1.Equals(mapped2).Should().BeTrue(); }