private static HttpClient GetClient(DependencyInjectionModel instance)
        {
            IEdmModel model       = GetEdmModel();
            var       controllers = new[] { typeof(DependencyInjectionModelsController) };
            var       server      = TestServerFactory.Create(controllers, config =>
            {
                config.MapODataServiceRoute("odata", "odata", builder =>
                                            builder.AddService(ServiceLifetime.Singleton, sp => instance)
                                            .AddService(ServiceLifetime.Singleton, sp => model)
                                            .AddService <IEnumerable <IODataRoutingConvention> >(ServiceLifetime.Singleton, sp =>
                                                                                                 ODataRoutingConventions.CreateDefaultWithAttributeRouting("odata", config)));
            });

            return(TestServerFactory.CreateClient(server));
        }
        public async Task CanAccessContainer_InODataController()
        {
            // Arrange
            const string             Uri      = "http://localhost/odata/DependencyInjectionModels";
            int                      randomId = new Random().Next();
            DependencyInjectionModel instance = new DependencyInjectionModel {
                Id = randomId
            };
            HttpClient client = GetClient(instance);

            // Act
            HttpResponseMessage response = await client.GetAsync(Uri);

            // Assert
            Assert.True(response.IsSuccessStatusCode);

            var result = JObject.Parse(await response.Content.ReadAsStringAsync());

            Assert.Equal("http://localhost/odata/$metadata#DependencyInjectionModels/$entity", result["@odata.context"]);
            Assert.Equal(randomId, result["Id"]);
        }