Esempio n. 1
0
        public MockHttpClientFactory(Database db, bool defaultFail = true)
        {
            HttpHandler = new MockHttpRequestHandler(defaultFail);
            HttpHandler.CookieContainer        = new CookieStore(db, "MockHttpClient");
            HttpHandler.UseCookies             = true;
            HttpHandler.AutomaticDecompression = System.Net.DecompressionMethods.Deflate | System.Net.DecompressionMethods.GZip;

            Headers = new Dictionary <string, string>();
        }
        public MockHttpClientFactory(Database db, bool defaultFail = true)
        {
            HttpHandler = new MockHttpRequestHandler(defaultFail);
            HttpHandler.CookieContainer = new CookieStore(db, "MockHttpClient");
            HttpHandler.UseCookies = true;
            HttpHandler.AutomaticDecompression = System.Net.DecompressionMethods.Deflate | System.Net.DecompressionMethods.GZip;

            Headers = new Dictionary<string,string>();
        }
        public MockHttpClientFactory(DirectoryInfo cookieStoreDirectory)
        {
            cookieStore = new CookieStore(cookieStore != null
                ? cookieStoreDirectory.FullName
                : null);
            HttpHandler = new MockHttpRequestHandler();
            HttpHandler.CookieContainer = cookieStore;
            HttpHandler.UseCookies      = true;

            Headers = new Dictionary <string, string>();
        }
        public MockHttpClientFactory(DirectoryInfo cookieStoreDirectory, bool defaultFail = true)
        {
            cookieStore = new CookieStore(cookieStoreDirectory != null 
                ? cookieStoreDirectory.FullName
                : null);
            HttpHandler = new MockHttpRequestHandler(defaultFail);
            HttpHandler.CookieContainer = cookieStore;
            HttpHandler.UseCookies = true;

            Headers = new Dictionary<string,string>();
        }
        public MockHttpClientFactory(DirectoryInfo cookieStoreDirectory, bool defaultFail = true)
        {
            cookieStore = new CookieStore(cookieStoreDirectory != null
                ? cookieStoreDirectory.FullName
                : null);
            HttpHandler = new MockHttpRequestHandler(defaultFail);
            HttpHandler.CookieContainer        = cookieStore;
            HttpHandler.UseCookies             = true;
            HttpHandler.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;

            Headers = new Dictionary <string, string>();
        }
        public MockHttpClientFactory(DirectoryInfo cookieStoreDirectory, bool defaultFail = true)
        {
            cookieStore = new CookieStore(cookieStoreDirectory != null 
                ? cookieStoreDirectory.FullName
                : null);
            HttpHandler = new MockHttpRequestHandler(defaultFail);
            HttpHandler.CookieContainer = cookieStore;
            HttpHandler.UseCookies = true;
            HttpHandler.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;

            Headers = new Dictionary<string,string>();
        }
        private void ValidateHttpHeaders (MockHttpRequestHandler mockHttpHandler)
        {
            var foundFooHeader = false;
            var requests = mockHttpHandler.CapturedRequests;

            foreach (var request in requests) {
                var requestHeaders = request.Headers.GetValues ("foo");
                foundFooHeader = false;
                foreach (var requestHeader in requestHeaders) {
                    foundFooHeader = true;
                    Assert.AreEqual ("bar", requestHeader);
                }
            }
            Assert.IsTrue (foundFooHeader);
        }