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 MapJsonWithPrimitiveEnumerable_Expected_RootPrimitivePath() { JsonMapper jsonMapper = new JsonMapper(); string json = GivenPrimitiveRecordset(); IEnumerable<IPath> paths = jsonMapper.Map(json); bool condition = paths.Any(p => p.ActualPath == JsonPath.EnumerableSymbol + JsonPath.SeperatorSymbol); Assert.IsTrue(condition); }
public void MapJsonWithNestedRecordsetsContainingScalarValues_Expected_PathToPropertyOfEnumerable() { JsonMapper jsonMapper = new JsonMapper(); string json = Given(); IEnumerable<IPath> paths = jsonMapper.Map(json); Assert.IsTrue(paths.Any(p => p.ActualPath == "Departments().Employees().Name")); }
public void MapJsonWithARecordsetContainingScalarValues_Expected_PathToEnumerable() { JsonMapper jsonMapper = new JsonMapper(); string json = Given(); IEnumerable<IPath> paths = jsonMapper.Map(json); Assert.IsTrue(paths.Any(p => p.ActualPath == "PrimitiveRecordset()")); }
public void MapJsonWithARecordset_Expected_PathToPropertyOnEnumerable() { JsonMapper jsonMapper = new JsonMapper(); string json = Given(); IEnumerable<IPath> paths = jsonMapper.Map(json); Assert.IsTrue(paths.Any(p => p.ActualPath == "Departments().Name")); }
public void MapJsonWithScalarValue_Expected_PathToScalarValue() { JsonMapper jsonMapper = new JsonMapper(); string json = Given(); IEnumerable<IPath> paths = jsonMapper.Map(json); Assert.IsTrue(paths.Any(p => p.ActualPath == "Motto")); }