//[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();
        }
Exemple #2
0
        public async Task WithItems()
        {
            String request = $"Orders/WithItems(itemIds=[1,2,3])";

            IList <Model.OrderItem> fromOe = null;
            Uri uri = DbFixtureInitDb.ContainerFactory().BaseUri;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new UriBuilder(uri.Scheme, uri.Host, uri.Port).Uri;
                client.DefaultRequestHeaders.TryAddWithoutValidation("Accept", OeRequestHeaders.JsonDefault.ContentType);
                using (HttpResponseMessage httpResponseMessage = await client.GetAsync(uri.LocalPath + "/" + request))
                    if (httpResponseMessage.IsSuccessStatusCode)
                    {
                        using (Stream content = await httpResponseMessage.Content.ReadAsStreamAsync())
                        {
                            var responseReader = new ResponseReader(Fixture.EdmModel);
                            fromOe = responseReader.Read <Model.OrderItem>(content).ToList();
                        }
                    }
            }

            Assert.Equal(new[] { 1, 2, 3 }, fromOe == null ? Enumerable.Empty <int>() : fromOe.Select(i => i.Id).OrderBy(id => id));
        }
        //[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(new Uri(parser.BaseUri + 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();
        }
 protected ModelBoundTest(DbFixtureInitDb fixture)
 {
     fixture.Initalize().GetAwaiter().GetResult();
     Fixture = fixture;
 }
 protected ManyColumnsFixtureInitDb(Type fixtureType, bool useRelationalNulls, ModelBoundTestKind modelBoundTestKind)
     : base(DbFixtureInitDb.CreateEdmModel(fixtureType, useRelationalNulls), modelBoundTestKind, useRelationalNulls)
 {
 }
 protected ManyColumnsFixtureInitDb(Type _, bool useRelationalNulls, ModelBoundTestKind modelBoundTestKind)
     : base(DbFixtureInitDb.CreateOeEdmModel(useRelationalNulls), modelBoundTestKind, useRelationalNulls)
 {
     _useRelationalNulls = useRelationalNulls;
 }
 protected ManyColumnsFixtureInitDb(Type _, bool __, ModelBoundTestKind modelBoundTestKind)
     : base(DbFixtureInitDb.CreateEdmModel(), modelBoundTestKind, false)
 {
 }