public void SelectEnumerableValuesAsRelatedUsingPocoEnumerablePathsFromReferenceType_Where_PathsContainNestedEnumerablePaths_Expected_FlattenedDataWithValuesFromOuterEnumerablePathRepeatingForEveryValueFromNestedEnumerablePath()
        {
            PocoTestData testData = GivenPocoWithParallelAndNestedEnumerables();

            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
            };

            IDataBrowser dataBrowser = DataBrowserFactory.CreateDataBrowser();
            Dictionary <IPath, IList <object> > data = dataBrowser.SelectEnumerablesAsRelated(paths, testData);

            #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);
        }
        public void MapPathsOfReferenceType_Expected_PocoPaths()
        {
            PocoTestData testData = GivenPoco();

            IDataBrowser        dataBrowser = DataBrowserFactory.CreateDataBrowser();
            IEnumerable <IPath> paths       = dataBrowser.Map(testData);

            Assert.IsTrue(paths.All(p => p.GetType() == typeof(PocoPath)));
        }
        public void SelectScalarValueUsingPocoScalarPathFromReferenceType_Expected_ScalarValue()
        {
            PocoTestData testData = GivenPoco();

            IPath        namePath    = new PocoPath("Name", "Name");
            IDataBrowser dataBrowser = DataBrowserFactory.CreateDataBrowser();

            object data = dataBrowser.SelectScalar(namePath, testData);

            Assert.AreEqual(data, testData.Name);
        }
        public void SelectEnumerableValueUsingPocoEnumerablePathFromReferenceType_Expected_ValuesFromEachItemInEnumeration()
        {
            PocoTestData testData = GivenPoco();

            IPath        namePath    = new PocoPath("EnumerableData().Name", "EnumerableData.Name");
            IDataBrowser dataBrowser = DataBrowserFactory.CreateDataBrowser();

            IEnumerable <object> data = dataBrowser.SelectEnumerable(namePath, testData);

            string expected = string.Join("|", testData.EnumerableData.Select(e => e.Name));
            string actual   = string.Join("|", data.Select(o => o.ToString()));

            Assert.AreEqual(expected, actual);
        }
Esempio n. 5
0
        internal PocoTestData GivenWithNoEnumerableData()
        {
            PocoTestData testData = new PocoTestData
            {
                Name = "Brendon",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherBrendon",
                    Age = 31,
                },
            };

            return testData;
        }
        internal PocoTestData GivenPoco()
        {
            PocoTestData testData = new PocoTestData
            {
                Name       = "Brendon",
                Age        = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherBrendon",
                    Age  = 31,
                },
            };

            PocoTestData nestedTestData1 = new PocoTestData
            {
                Name       = "Mo",
                Age        = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherMo",
                    Age  = 31,
                },
            };

            PocoTestData nestedTestData2 = new PocoTestData
            {
                Name       = "Trav",
                Age        = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherTrav",
                    Age  = 31,
                },
            };

            testData.EnumerableData = new List <PocoTestData> {
                nestedTestData1, nestedTestData2
            };

            return(testData);
        }
Esempio n. 7
0
        internal PocoTestData GivenPoco()
        {
            PocoTestData testData = new PocoTestData
            {
                Name = "Brendon",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherBrendon",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData1 = new PocoTestData
            {
                Name = "Mo",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherMo",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData2 = new PocoTestData
            {
                Name = "Trav",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherTrav",
                    Age = 31,
                },
            };

            testData.EnumerableData = new List<PocoTestData> { nestedTestData1, nestedTestData2 };

            return testData;
        }
Esempio n. 8
0
        internal PocoTestData GivenPocoWithParallelAndNestedEnumerables()
        {
            PocoTestData testData = new PocoTestData
            {
                Name = "Brendon",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherBrendon",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData1 = new PocoTestData
            {
                Name = "Mo",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherMo",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData2 = new PocoTestData
            {
                Name = "Trav",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherTrav",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData3 = new PocoTestData
            {
                Name = "Jayd",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherJayd",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData4 = new PocoTestData
            {
                Name = "Dan",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherDan",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData5 = new PocoTestData
            {
                Name = "Mark",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherMark",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData6 = new PocoTestData
            {
                Name = "Warren",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherWarren",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData7 = new PocoTestData
            {
                Name = "Wallis",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherWallis",
                    Age = 31,
                },
            };

            nestedTestData1.EnumerableData = new List<PocoTestData> { nestedTestData3, nestedTestData4, nestedTestData6 };
            nestedTestData2.EnumerableData = new List<PocoTestData> { nestedTestData5 };

            testData.EnumerableData = new List<PocoTestData> { nestedTestData1, nestedTestData2 };
            testData.EnumerableData1 = new List<PocoTestData> { nestedTestData3, nestedTestData4, nestedTestData5, nestedTestData6, nestedTestData7 };

            return testData;
        }
        internal PocoTestData GivenPocoWithParallelAndNestedEnumerables()
        {
            PocoTestData testData = new PocoTestData
            {
                Name = "Brendon",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherBrendon",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData1 = new PocoTestData
            {
                Name = "Mo",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherMo",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData2 = new PocoTestData
            {
                Name = "Trav",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherTrav",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData3 = new PocoTestData
            {
                Name = "Jayd",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherJayd",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData4 = new PocoTestData
            {
                Name = "Dan",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherDan",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData5 = new PocoTestData
            {
                Name = "Mark",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherMark",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData6 = new PocoTestData
            {
                Name = "Warren",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherWarren",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData8 = new PocoTestData
            {
                Name = "Franco",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherFranco",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData9 = new PocoTestData
            {
                Name = "Taryn",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherTaryn",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData10 = new PocoTestData
            {
                Name = "Melissa",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherMelissa",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData11 = new PocoTestData
            {
                Name = "Melanie",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherMelanie",
                    Age = 31,
                },
            };

            PocoTestData nestedTestData12 = new PocoTestData
            {
                Name = "Justin",
                Age = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherJustin",
                    Age = 31,
                },
            };


            nestedTestData1.EnumerableData = new List<PocoTestData> { nestedTestData3, nestedTestData4, nestedTestData6 };
            nestedTestData2.EnumerableData = new List<PocoTestData> { nestedTestData5 };

            testData.EnumerableData = new List<PocoTestData> { nestedTestData1, nestedTestData2 };
            testData.EnumerableData1 = new List<PocoTestData> { nestedTestData8, nestedTestData9, nestedTestData10, nestedTestData11, nestedTestData12 };

            return testData;
        }
        internal PocoTestData GivenPocoWithParallelAndNestedEnumerables()
        {
            PocoTestData testData = new PocoTestData
            {
                Name       = "Brendon",
                Age        = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherBrendon",
                    Age  = 31,
                },
            };

            PocoTestData nestedTestData1 = new PocoTestData
            {
                Name       = "Mo",
                Age        = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherMo",
                    Age  = 31,
                },
            };

            PocoTestData nestedTestData2 = new PocoTestData
            {
                Name       = "Trav",
                Age        = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherTrav",
                    Age  = 31,
                },
            };

            PocoTestData nestedTestData3 = new PocoTestData
            {
                Name       = "Jayd",
                Age        = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherJayd",
                    Age  = 31,
                },
            };

            PocoTestData nestedTestData4 = new PocoTestData
            {
                Name       = "Dan",
                Age        = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherDan",
                    Age  = 31,
                },
            };

            PocoTestData nestedTestData5 = new PocoTestData
            {
                Name       = "Mark",
                Age        = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherMark",
                    Age  = 31,
                },
            };

            PocoTestData nestedTestData6 = new PocoTestData
            {
                Name       = "Warren",
                Age        = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherWarren",
                    Age  = 31,
                },
            };

            PocoTestData nestedTestData7 = new PocoTestData
            {
                Name       = "Wallis",
                Age        = 30,
                NestedData = new PocoTestData
                {
                    Name = "AnotherWallis",
                    Age  = 31,
                },
            };

            nestedTestData1.EnumerableData = new List <PocoTestData> {
                nestedTestData3, nestedTestData4, nestedTestData6
            };
            nestedTestData2.EnumerableData = new List <PocoTestData> {
                nestedTestData5
            };

            testData.EnumerableData = new List <PocoTestData> {
                nestedTestData1, nestedTestData2
            };
            testData.EnumerableData1 = new List <PocoTestData> {
                nestedTestData3, nestedTestData4, nestedTestData5, nestedTestData6, nestedTestData7
            };

            return(testData);
        }