SelectEnumerablesAsRelated() public method

public SelectEnumerablesAsRelated ( IList paths ) : IList>.Dictionary
paths IList
return IList>.Dictionary
Esempio n. 1
0
        public void SelectEnumerableValuesAsRelatedFromReferenceType_Where_PathsContainASinglePathWhichIsScalar_Expected_FlattenedDataWithValueFromScalarPath()
        {
            PocoTestData testData = GivenWithParallelAndNestedEnumerables();

            PocoPath namePath = new PocoPath("Name", "Name");
            List<IPath> paths = new List<IPath> { namePath };

            PocoNavigator pocoNavigator = new PocoNavigator(testData);
            Dictionary<IPath, IList<object>> data = pocoNavigator.SelectEnumerablesAsRelated(paths);

            string expected = testData.Name;
            string actual = string.Join("|", data[namePath]);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public void SelectEnumerableValuesUsingRootPathFromEnumerableContainingOnlyPrimitives_Expected_ValuesForEachValueInEnumeration()
        {
            List<int> testData = new List<int> { 1, 2, 3 };

            IPath path = new PocoPath("().", "().");
            List<IPath> paths = new List<IPath> { path };

            PocoNavigator pocoNavigator = new PocoNavigator(testData);

            Dictionary<IPath, IList<object>> data = pocoNavigator.SelectEnumerablesAsRelated(paths);

            string expected = string.Join("|", testData.Select(e => e));
            string actual = string.Join("|", data[path]);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public void SelectEnumerableValuesAsRelatedFromReferenceType_Where_PathsContainNestedEnumerablePaths_Expected_FlattenedDataWithValuesFromOuterEnumerablePathRepeatingForEveryValueFromNestedEnumerablePath()
        {
            PocoTestData testData = GivenWithParallelAndNestedEnumerables();

            PocoPath enumerableNamePath = new PocoPath("EnumerableData().Name", "EnumerableData.Name");
            PocoPath nestedEnumerableNamePath = new PocoPath("EnumerableData().EnumerableData().Name", "EnumerableData.EnumerableData.Name");
            List<IPath> paths = new List<IPath> { enumerableNamePath, nestedEnumerableNamePath };

            PocoNavigator pocoNavigator = new PocoNavigator(testData);
            Dictionary<IPath, IList<object>> data = pocoNavigator.SelectEnumerablesAsRelated(paths);

            #region Complex Setup for Expected

            //
            // The code in this region is used to setup the exprected value.
            // It can't be reused for other tests and can't be made generic
            // without replicating the funcationality being tested.
            //
            string tmpExpected = "";
            string tmpExpected1 = "";
            string separator = "|";

            for (int outerCount = 0; outerCount < testData.EnumerableData.Count; outerCount++)
            {
                for (int innerCount = 0; innerCount < testData.EnumerableData[outerCount].EnumerableData.Count; innerCount++)
                {
                    if (outerCount == testData.EnumerableData.Count - 1 && innerCount == testData.EnumerableData[outerCount].EnumerableData.Count - 1) separator = "";
                    if (outerCount < testData.EnumerableData.Count)
                    {
                        tmpExpected += testData.EnumerableData[outerCount].Name + separator;
                    }
                    else
                    {
                        tmpExpected += separator;
                    }

                    if (innerCount < testData.EnumerableData[outerCount].EnumerableData.Count)
                    {
                        tmpExpected1 += testData.EnumerableData[outerCount].EnumerableData[innerCount].Name + separator;
                    }
                    else
                    {
                        tmpExpected1 += separator;
                    }
                }
            }

            #endregion Complex Setup for Expected

            string expected = tmpExpected + "^" + tmpExpected1;
            string actual = string.Join("|", data[enumerableNamePath]);
            actual += "^" + string.Join("|", data[nestedEnumerableNamePath]);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 4
0
        public void SelectEnumerableValuesAsRelatedUsingRootPathFromPrimitive_Expected_SingleValueInEnumeration()
        {
            Given();

            IPath path = new PocoPath(PocoPath.SeperatorSymbol, PocoPath.SeperatorSymbol);
            List<IPath> paths = new List<IPath> { path };

            PocoNavigator pocoNavigator = new PocoNavigator(1);

            Dictionary<IPath, IList<object>> data = pocoNavigator.SelectEnumerablesAsRelated(paths);

            const string expected = "1";
            string actual = string.Join("|", data[path]);

            Assert.AreEqual(expected, actual);
        }