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); } } }
//[Fact] public void CacheCode() { var hashes = new Dictionary <int, List <String> >(); SelectTestDefinition[] requestMethodNames = SelectTestDefinition.GetSelectTestDefinitions(); var fixture = new RDBNull_DbFixtureInitDb(); for (int i = 0; i < requestMethodNames.Length; i++) { var queryContext = new OeQueryContext(fixture.OeEdmModel, fixture.ParseUri(requestMethodNames[i].Request)); 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(); }
//[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(); }