コード例 #1
0
ファイル: OpenTypeMethods.cs プロジェクト: larsenjo/odata.net
 public static object TypeIs(object value, Edm.IEdmTypeReference typeReference)
 {
     throw new NotImplementedException();
 }
コード例 #2
0
        public void SkipAndTopBinderTest()
        {
            IEdmModel model = QueryTestMetadata.BuildTestMetadata(this.PrimitiveTypeResolver, this.UntypedDataServiceProviderFactory);

            var testCases = new[]
            {
                new SkipTopTestCase
                {
                    Query = "/Customers?$skip=2",
                    ExpectedSkipClause = 2
                },
                new SkipTopTestCase
                {
                    Query = "/Customers?$top=2",
                    ExpectedTopClause = 2
                },
                new SkipTopTestCase
                {
                    Query = "/Customers?$skip=3&$top=2",
                    ExpectedTopClause = 2,
                    ExpectedSkipClause = 3
                },
                new SkipTopTestCase
                {
                    Query = "/Customers?$top=2&$skip=3",
                    ExpectedTopClause = 2,
                    ExpectedSkipClause = 3
                },
                // TODO: enable those?
                /* 
                new SkipTopTestCase
                {
                    Query = "/Customers(0)?$top=100",
                    ExpectedExceptionMessage = "The $top query option cannot be applied to the query path. Top can only be applied to a collection of entities."
                },
                new SkipTopTestCase
                {
                    Query = "/Customers(0)?$skip=100",
                    ExpectedExceptionMessage = "The $skip query option cannot be applied to the query path. Skip can only be applied to a collection of entities."
                },
                new SkipTopTestCase
                {
                    Query = "/Customers(0)?$skip=100&top=100",
                    ExpectedExceptionMessage = "The $skip query option cannot be applied to the query path. Skip can only be applied to a collection of entities."
                },
                new SkipTopTestCase
                {
                    Query = "/Customers(0)?top=100&$skip=100",
                    ExpectedExceptionMessage = "The $skip query option cannot be applied to the query path. Skip can only be applied to a collection of entities."
                },
                 */
            };

            this.CombinatorialEngineProvider.RunCombinations(
                testCases,
                (testCase) =>
                {
                    TestExceptionUtils.ExpectedException<ODataException>(
                        this.Assert,
                        () =>
                        {
                            ODataUri actual = QueryNodeUtils.BindQuery(testCase.Query, model);
                            if (testCase.ExpectedSkipClause != null)
                            {
                                Assert.AreEqual(testCase.ExpectedSkipClause, actual.Skip, "Skip amounts are not equal!");
                            }
                            
                            if (testCase.ExpectedTopClause != null)
                            {
                                Assert.AreEqual(testCase.ExpectedTopClause, actual.Top, "Top amounts are not equal!");
                            }
                        },
                        testCase.ExpectedExceptionMessage,
                        null);
                });
        }