SelectScalar() public method

public SelectScalar ( IPath path ) : object
path IPath
return object
Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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");
        }