public void SelectEnumerableValuesAsRelatedFromReferenceType_Where_PathsContainUnrelatedEnumerablePaths_Expected_FlattenedDataWithValuesFromUnrelatedEnumerablePathsAtMatchingIndexes() { PocoTestData testData = GivenWithParallelAndNestedEnumerables(); PocoPath enumerableNamePath = new PocoPath("EnumerableData().Name", "EnumerableData.Name"); PocoPath parallelEnumerableNamePath = new PocoPath("EnumerableData1().Name", "EnumerableData1.Name"); //PocoPath nestedEnumerableNamePath = new PocoPath("EnumerableData().EnumerableData().Name", "EnumerableData.EnumerableData.Name"); List <IPath> paths = new List <IPath> { enumerableNamePath, parallelEnumerableNamePath }; PocoNavigator pocoNavigator = new PocoNavigator(testData); Dictionary <IPath, IList <object> > data = pocoNavigator.SelectEnumerablesAsRelated(paths); int maxCount = Math.Max(testData.EnumerableData.Count, testData.EnumerableData1.Count); #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 i = 0; i < maxCount; i++) { if (i == maxCount - 1) { separator = ""; } if (i < testData.EnumerableData.Count) { tmpExpected += testData.EnumerableData[i].Name + separator; } else { tmpExpected += separator; } if (i < testData.EnumerableData1.Count) { tmpExpected1 += testData.EnumerableData1[i].Name + separator; } else { tmpExpected1 += separator; } } #endregion Complex Setup for Expected string expected = tmpExpected + "^" + tmpExpected1; string actual = string.Join("|", data[enumerableNamePath]); actual += "^" + string.Join("|", data[parallelEnumerableNamePath]); Assert.AreEqual(expected, actual); }
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); }
public void SelectEnumerableValuesAsRelatedFromReferenceType_Where_PathsContainNestedEnumerablePaths_Expected_FlattenedDataWithValuesFromOuterEnumerablePathRepeatingForEveryValueFromNestedEnumerablePath() { var testData = GivenWithParallelAndNestedEnumerables(); var enumerableNamePath = new PocoPath("EnumerableData().Name", "EnumerableData.Name"); var nestedEnumerableNamePath = new PocoPath("EnumerableData().EnumerableData().Name", "EnumerableData.EnumerableData.Name"); var paths = new List <IPath> { enumerableNamePath, nestedEnumerableNamePath }; var pocoNavigator = new PocoNavigator(testData); var data = pocoNavigator.SelectEnumerablesAsRelated(paths); var tmpExpected = ""; var tmpExpected1 = ""; var 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; } } } var expected = tmpExpected + "^" + tmpExpected1; var actual = string.Join("|", data[enumerableNamePath]); actual += "^" + string.Join("|", data[nestedEnumerableNamePath]); Assert.AreEqual(expected, actual); }
public void SelectEnumerableValuesAsRelatedFromReferenceType_Where_PathsContainUnrelatedEnumerablePaths_Expected_FlattenedDataWithValuesFromUnrelatedEnumerablePathsAtMatchingIndexes() { var testData = GivenWithParallelAndNestedEnumerables(); var enumerableNamePath = new PocoPath("EnumerableData().Name", "EnumerableData.Name"); var parallelEnumerableNamePath = new PocoPath("EnumerableData1().Name", "EnumerableData1.Name"); var paths = new List <IPath> { enumerableNamePath, parallelEnumerableNamePath }; var pocoNavigator = new PocoNavigator(testData); var data = pocoNavigator.SelectEnumerablesAsRelated(paths); var maxCount = Math.Max(testData.EnumerableData.Count, testData.EnumerableData1.Count); var tmpExpected = ""; var tmpExpected1 = ""; var separator = "|"; for (int i = 0; i < maxCount; i++) { if (i == maxCount - 1) { separator = ""; } if (i < testData.EnumerableData.Count) { tmpExpected += testData.EnumerableData[i].Name + separator; } else { tmpExpected += separator; } if (i < testData.EnumerableData1.Count) { tmpExpected1 += testData.EnumerableData1[i].Name + separator; } else { tmpExpected1 += separator; } } var expected = tmpExpected + "^" + tmpExpected1; var actual = string.Join("|", data[enumerableNamePath]); actual += "^" + string.Join("|", data[parallelEnumerableNamePath]); Assert.AreEqual(expected, actual); }
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); }
public void SelectEnumerableValuesAsRelatedFromReferenceType_Where_PathsContainASinglePathWhichIsEnumerable_Expected_FlattenedDataWithValuesFromEnumerablePath() { var testData = GivenWithParallelAndNestedEnumerables(); var enumerableNamePath = new PocoPath("EnumerableData().Name", "EnumerableData.Name"); var paths = new List <IPath> { enumerableNamePath }; var pocoNavigator = new PocoNavigator(testData); var data = pocoNavigator.SelectEnumerablesAsRelated(paths); var expected = string.Join("|", testData.EnumerableData.Select(e => e.Name)); var actual = string.Join("|", data[enumerableNamePath]); Assert.AreEqual(expected, actual); }
public void SelectEnumerableValuesAsRelatedUsingRootPathFromPrimitive_Expected_SingleValueInEnumeration() { PocoTestData testData = 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); string expected = "1"; string actual = string.Join("|", data[path]); Assert.AreEqual(expected, actual); }
public void SelectEnumerableValuesAsRelatedFromReferenceType_Where_PathsContainAScalarPath_Expected_FlattenedDataWithValueFromScalarPathRepeatingForEachEnumeration() { var testData = GivenWithParallelAndNestedEnumerables(); var namePath = new PocoPath("Name", "Name"); var enumerableNamePath = new PocoPath("EnumerableData().Name", "EnumerableData.Name"); var paths = new List <IPath> { namePath, enumerableNamePath }; var pocoNavigator = new PocoNavigator(testData); var data = pocoNavigator.SelectEnumerablesAsRelated(paths); var expected = string.Join("|", testData.EnumerableData.Select(e => testData.Name)); var actual = string.Join("|", data[namePath]); Assert.AreEqual(expected, actual); }
public void SelectEnumerableValuesAsRelatedUsingRootPathFromPrimitive_Expected_SingleValueInEnumeration() { Given(); IPath path = new PocoPath(PocoPath.SeperatorSymbol, PocoPath.SeperatorSymbol); var paths = new List <IPath> { path }; var pocoNavigator = new PocoNavigator(1); var data = pocoNavigator.SelectEnumerablesAsRelated(paths); const string expected = "1"; var actual = string.Join("|", data[path]); Assert.AreEqual(expected, actual); }
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); }