public IMapper CreateMapper(object data) { IMapper mapper; if (IsXml(data.ToString())) { mapper = new XmlMapper(); } else if (IsJson(data.ToString())) { mapper = new JsonMapper(); } else { if(data.GetType().IsPrimitive) { mapper = new PocoMapper(); } else { mapper = new StringMapper(); } } return mapper; }
public void MapXmlWithScalarValue_Expected_PathToScalarValue() { XmlMapper xmlMapper = new XmlMapper(); string xml = Given(); IEnumerable<IPath> paths = xmlMapper.Map(xml); Assert.IsTrue(paths.Any(p => p.ActualPath == "Company.Motto")); }
public void MapXmlWithAttribute_Expected_PathToAttribute() { XmlMapper xmlMapper = new XmlMapper(); string xml = Given(); IEnumerable<IPath> paths = xmlMapper.Map(xml); Assert.IsTrue(paths.Any(p => p.ActualPath == "Company:Name")); }
public void MapXmlWithAInlineRecordset_Expected_PathToItemsInInnerRecordset() { XmlMapper xmlMapper = new XmlMapper(); string xml = Given(); IEnumerable<IPath> paths = xmlMapper.Map(xml); Assert.IsTrue(paths.Any(p => p.ActualPath == "Company().InlineRecordSet")); }
public void MapXmlWithARecordsetAndAttributesOnTheRecordset_Expected_PathToAttributeOfRecordset() { XmlMapper xmlMapper = new XmlMapper(); string xml = Given(); IEnumerable<IPath> paths = xmlMapper.Map(xml); Assert.IsTrue(paths.Any(p => p.ActualPath == "Company.Departments:TestAttrib")); }