public SelectScalar ( IPath path ) : object | ||
path | IPath | |
Résultat | object |
public void SelectEnumerableValuesUsingEnumerablePathFromReferenceType_Where_EnumerableDataIsNull_Expected_Null() { PocoTestData testData = GivenWithNoEnumerableData(); IPath namePath = new PocoPath("EnumerableData().Name", "EnumerableData.Name"); PocoNavigator pocoNavigator = new PocoNavigator(testData); object data = pocoNavigator.SelectScalar(namePath); Assert.AreEqual(data, null); }
public void SelectScalarValueUsingEnumerablePathFromReferenceType_Expected_ScalarValueFromLastItemInEnumerableCollection() { PocoTestData testData = Given(); IPath namePath = new PocoPath("EnumerableData().NestedData.Name", "EnumerableData.NestedData.Name"); PocoNavigator pocoNavigator = new PocoNavigator(testData); object data = pocoNavigator.SelectScalar(namePath); Assert.AreEqual(data, testData.EnumerableData.ElementAt(testData.EnumerableData.Count - 1).NestedData.Name); }
public void SelectScalarValueUsingScalarPathFromReferenceType_Expected_ScalarValue() { PocoTestData testData = Given(); IPath namePath = new PocoPath("Name", "Name"); PocoNavigator pocoNavigator = new PocoNavigator(testData); object data = pocoNavigator.SelectScalar(namePath); Assert.AreEqual(data, testData.Name); }
public void SelectScalarValueUsingScalarPathFromEnumerable_Expected_ScalarValue() { PocoTestData testData = Given(); IPath path = new PocoPath("EnumerableData.Count", "EnumerableData.Count"); PocoNavigator pocoNavigator = new PocoNavigator(testData); object data = pocoNavigator.SelectScalar(path); Assert.AreEqual(data, testData.EnumerableData.Count); }
public void SelectScalarValueUsingRootPathFromEnumerableContainingOnlyPrimitives_Expected_LastScalarValueInEnumeration() { List<int> testData = new List<int> { 1, 2, 3 }; IPath namePath = new PocoPath("().", "()."); PocoNavigator pocoNavigator = new PocoNavigator(testData); const string expected = "3"; string actual = pocoNavigator.SelectScalar(namePath).ToString(); Assert.AreEqual(expected, actual); }
public void SelectScalarValueUsingRootPathFromPrimitive_Expected_ScalarValue() { Given(); IPath path = new PocoPath(PocoPath.SeperatorSymbol, PocoPath.SeperatorSymbol); PocoNavigator pocoNavigator = new PocoNavigator(1); object data = pocoNavigator.SelectScalar(path); Assert.AreEqual(data, "1"); }