Beispiel #1
0
        public void GivenIHaveAnAPIRunningCacheCowServerAndUsingStorage(string storage)
        {
            IEntityTagStore store;
            var             configuration = new HttpConfiguration();

            switch (storage)
            {
            case "InMemory":
                store = new InMemoryEntityTagStore();
                break;

            case "InMemoryFaulty":
                store = new FaultyInMemoryStore();
                break;

            default:
                throw new ArgumentException("Store unknown: " + storage);
            }

            configuration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            var inMemoryServer = new InMemoryServer(configuration);
            var cachingHandler = new CachingHandler("test", "1.0.0", configuration, store, "Accept")
            {
                InnerHandler = inMemoryServer
            };
            var client = new HttpClient(cachingHandler);

            ScenarioContext.Current[Keys.Client]       = client;
            ScenarioContext.Current[Keys.CacheHandler] = cachingHandler;
        }
Beispiel #2
0
        public void GivenIHaveAnAPIRunningCacheCowServerAndUsingStorage(string storage)
        {
            IEntityTagStore store;
            var configuration = new HttpConfiguration();
            switch (storage)
            {
                case "InMemory":
                    store = new InMemoryEntityTagStore();
                    break;
                case "InMemoryFaulty":
                    store = new FaultyInMemoryStore();
                    break;
                default:
                    throw new ArgumentException("Store unknown: " + storage);
            }

            configuration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            var inMemoryServer = new InMemoryServer(configuration);
            var cachingHandler = new CachingHandler(configuration, store, "Accept")
            {
                InnerHandler = inMemoryServer
            };
            var client = new HttpClient(cachingHandler);

            ScenarioContext.Current[Keys.Client] = client;
            ScenarioContext.Current[Keys.CacheHandler] = cachingHandler;
        }