private string GetSampleData(object root, IPath path) { var navigator = new PocoNavigator(root); return(string.Join(GlobalConstants.AnythingToXmlPathSeperator, navigator.SelectEnumerable(path) .Select( o => o.ToString() .Replace(GlobalConstants.AnythingToXmlPathSeperator, GlobalConstants.AnytingToXmlCommaToken)) .Take(10))); }
public void SelectEnumerableValuesUsingScalarPathFromReferenceType_Expected_SingleValueInEnumeration() { PocoTestData testData = Given(); IPath namePath = new PocoPath("NestedData.Name", "NestedData.Name"); PocoNavigator pocoNavigator = new PocoNavigator(testData); IEnumerable<object> data = pocoNavigator.SelectEnumerable(namePath); string expected = testData.NestedData.Name; string actual = string.Join("", data.Select(o => o.ToString())); Assert.AreEqual(expected, actual); }
public void SelectEnumerableValuesUsingEnumerablePathFromReferenceType_Expected_ValuesFromEachItemInEnumeration() { PocoTestData testData = Given(); IPath namePath = new PocoPath("EnumerableData().Name", "EnumerableData.Name"); PocoNavigator pocoNavigator = new PocoNavigator(testData); IEnumerable<object> data = pocoNavigator.SelectEnumerable(namePath); string expected = string.Join("|", testData.EnumerableData.Select(e => e.Name)); string actual = string.Join("|", data.Select(o => o.ToString())); Assert.AreEqual(expected, actual); }
public void SelectEnumerableValuesAsRelatedUsingRootPathFromEnumerableContainingOnlyPrimitives_Expected_ValuesForEachValueInEnumeration() { List<int> testData = new List<int> { 1, 2, 3 }; IPath path = new PocoPath("().", "()."); PocoNavigator pocoNavigator = new PocoNavigator(testData); IEnumerable<object> data = pocoNavigator.SelectEnumerable(path); string expected = string.Join("|", testData.Select(e => e)); string actual = string.Join("|", data.Select(o => o.ToString())); Assert.AreEqual(expected, actual); }
public void SelectEnumerableValuesUsingRootPathFromPrimitive_Expected_SingleValueInEnumeration() { Given(); IPath path = new PocoPath(PocoPath.SeperatorSymbol, PocoPath.SeperatorSymbol); PocoNavigator pocoNavigator = new PocoNavigator(1); IEnumerable<object> data = pocoNavigator.SelectEnumerable(path); const string expected = "1"; string actual = string.Join("", data.Select(o => o.ToString())); Assert.AreEqual(expected, actual); }
private string GetSampleData(object root, IPath path) { var navigator = new PocoNavigator(root); return string.Join(GlobalConstants.AnythingToXmlPathSeperator, navigator.SelectEnumerable(path) .Select( o => o.ToString() .Replace(GlobalConstants.AnythingToXmlPathSeperator, GlobalConstants.AnytingToXmlCommaToken)) .Take(10)); }