SelectEnumerable() public method

public SelectEnumerable ( IPath path ) : IEnumerable
path IPath
return IEnumerable
示例#1
0
        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)));
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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));
 }