public void Test()
        {
            SelectTestDefinition[] requestMethodNames = SelectTestDefinition.GetSelectTestDefinitions();
            requestMethodNames = requestMethodNames.Where(t => t.MethodName == "FilterEnum" || t.MethodName == "FilterEnumNull").ToArray();

            var fixture = new DbFixtureInitDb();
            var parser  = new OeGetParser(fixture.OeDataAdapter, fixture.EdmModel);

            for (int i = 0; i < requestMethodNames.Length; i++)
            {
                OeQueryContext queryContext1 = parser.CreateQueryContext(fixture.ParseUri(requestMethodNames[i].Request), 0, false, OeMetadataLevel.Minimal);
                OeQueryContext queryContext2 = parser.CreateQueryContext(fixture.ParseUri(requestMethodNames[i].Request), 0, false, OeMetadataLevel.Minimal);

                var constantToParameterMapper = new FakeReadOnlyDictionary <ConstantNode, Db.OeQueryCacheDbParameterDefinition>();
                if (queryContext1.ODataUri.Skip != null)
                {
                    var constantNode = OeCacheComparerParameterValues.CreateSkipConstantNode((int)queryContext1.ODataUri.Skip.Value, queryContext1.ODataUri.Path);
                    constantToParameterMapper.Add(constantNode, new Db.OeQueryCacheDbParameterDefinition("p_0", typeof(int)));
                }
                if (queryContext1.ODataUri.Top != null)
                {
                    var constantNode = OeCacheComparerParameterValues.CreateTopConstantNode((int)queryContext1.ODataUri.Top.Value, queryContext1.ODataUri.Path);
                    constantToParameterMapper.Add(constantNode, new Db.OeQueryCacheDbParameterDefinition($"p_{constantToParameterMapper.Count}", typeof(int)));
                }

                OeCacheContext cacheContext1 = queryContext1.CreateCacheContext();
                OeCacheContext cacheContext2 = queryContext2.CreateCacheContext();
                bool           result        = new OeCacheComparer(constantToParameterMapper, false).Compare(cacheContext1, cacheContext2);
                Assert.True(result);

                for (int j = i + 1; j < requestMethodNames.Length; j++)
                {
                    queryContext2 = parser.CreateQueryContext(fixture.ParseUri(requestMethodNames[j].Request), 0, false, OeMetadataLevel.Minimal);

                    constantToParameterMapper = new FakeReadOnlyDictionary <ConstantNode, Db.OeQueryCacheDbParameterDefinition>();
                    result = new OeCacheComparer(constantToParameterMapper, false).Compare(cacheContext1, cacheContext2);
                    Assert.False(result);
                }
            }
        }
Example #2
0
        public void Test()
        {
            SelectTestDefinition[] requestMethodNames = TestHelper.GetSelectTestDefinitions();
            requestMethodNames = requestMethodNames.Where(t => t.MethodName == "FilterEnum" || t.MethodName == "FilterEnumNull").ToArray();

            var fixture = new DbFixtureInitDb();
            var baseUri = new Uri("http://dummy/");
            var parser  = new OeGetParser(baseUri, fixture.OeDataAdapter, fixture.EdmModel);

            for (int i = 0; i < requestMethodNames.Length; i++)
            {
                OeParseUriContext parseUriContext1 = parser.ParseUri(fixture.ParseUri(requestMethodNames[i].Request));
                OeParseUriContext parseUriContext2 = parser.ParseUri(fixture.ParseUri(requestMethodNames[i].Request));

                var constantToParameterMapper = new FakeReadOnlyDictionary <ConstantNode, Db.OeQueryCacheDbParameterDefinition>();
                if (parseUriContext1.ODataUri.Skip != null)
                {
                    var constantNode = OeODataUriComparerParameterValues.CreateSkipConstantNode((int)parseUriContext1.ODataUri.Skip.Value, parseUriContext1.ODataUri.Path);
                    constantToParameterMapper.Add(constantNode, new Db.OeQueryCacheDbParameterDefinition("p_0", typeof(int)));
                }
                if (parseUriContext1.ODataUri.Top != null)
                {
                    var constantNode = OeODataUriComparerParameterValues.CreateTopConstantNode((int)parseUriContext1.ODataUri.Top.Value, parseUriContext1.ODataUri.Path);
                    constantToParameterMapper.Add(constantNode, new Db.OeQueryCacheDbParameterDefinition($"p_{constantToParameterMapper.Count}", typeof(int)));
                }

                bool result = new OeODataUriComparer(constantToParameterMapper).Compare(parseUriContext1, parseUriContext2);
                Assert.True(result);

                for (int j = i + 1; j < requestMethodNames.Length; j++)
                {
                    parseUriContext2 = parser.ParseUri(fixture.ParseUri(requestMethodNames[j].Request));

                    constantToParameterMapper = new FakeReadOnlyDictionary <ConstantNode, Db.OeQueryCacheDbParameterDefinition>();
                    result = new OeODataUriComparer(constantToParameterMapper).Compare(parseUriContext1, parseUriContext2);
                    Assert.False(result);
                }
            }
        }
        //[Fact]
        public void CacheCode()
        {
            var hashes = new Dictionary <int, List <String> >();

            SelectTestDefinition[] requestMethodNames = SelectTestDefinition.GetSelectTestDefinitions();

            var fixture = new DbFixtureInitDb();
            var parser  = new OeGetParser(fixture.OeDataAdapter, fixture.EdmModel);

            for (int i = 0; i < requestMethodNames.Length; i++)
            {
                OeQueryContext queryContext = parser.CreateQueryContext(fixture.ParseUri(requestMethodNames[i].Request), 0, false, OeMetadataLevel.Minimal);
                int            hash         = OeCacheComparer.GetCacheCode(queryContext.CreateCacheContext());
                if (!hashes.TryGetValue(hash, out List <String> value))
                {
                    value = new List <String>();
                    hashes.Add(hash, value);
                }
                value.Add(requestMethodNames[i].MethodName);
            }

            var duplicate = hashes.Where(p => p.Value.Count > 1).Select(p => p.Value).ToArray();
        }
Example #4
0
        //[Fact]
        public void CacheCode()
        {
            var hashes = new Dictionary <int, List <String> >();

            SelectTestDefinition[] requestMethodNames = TestHelper.GetSelectTestDefinitions();

            var fixture = new DbFixtureInitDb();
            var parser  = new OeGetParser(new Uri("http://dummy/"), fixture.OeDataAdapter, fixture.EdmModel);

            for (int i = 0; i < requestMethodNames.Length; i++)
            {
                OeParseUriContext parseUriContext = parser.ParseUri(fixture.ParseUri(requestMethodNames[i].Request));
                int           hash = OeODataUriComparer.GetCacheCode(parseUriContext);
                List <String> value;
                if (!hashes.TryGetValue(hash, out value))
                {
                    value = new List <String>();
                    hashes.Add(hash, value);
                }
                value.Add(requestMethodNames[i].MethodName);
            }

            var duplicate = hashes.Where(p => p.Value.Count > 1).Select(p => p.Value).ToArray();
        }