Beispiel #1
0
        public static FakeHttpContext FakeHttpContextWithCookie(HttpCookie cookie)
        {
            var cookieColletion = new HttpCookieCollection();
            cookieColletion.Add(cookie);

            var fakeContext = new FakeHttpContext("/");
            var fakeRequest = new FakeHttpRequest("/", "get", new Uri("http://localhost"), new Uri("http://localhost"),
                                                  new NameValueCollection(), new NameValueCollection(), cookieColletion);

            var fakeResponse = new FakeHttpResponseForCookieHandeling();
            fakeContext.SetResponse(fakeResponse);
            fakeContext.SetRequest(fakeRequest);
            return fakeContext;
        }
        private FakeHttpContext CreateJONCookieInFakeHttpContextWith10ItemsInside()
        {
            var cookie = new HttpCookie("JON");
            cookie["wishlistitems"] = String.Join(",", fixture.CreateMany<int>(10));

            var cookieColletion = new HttpCookieCollection();
            cookieColletion.Add(cookie);

            var fakeContext = new FakeHttpContext("/");
            var fakeRequest = new FakeHttpRequest("/", "get", new Uri("http://localhost"), new Uri("http://localhost"),
                                                  new NameValueCollection(), new NameValueCollection(), cookieColletion);

            var fakeResponse = new FakeHttpResponseForCookieHandeling();
            fakeContext.SetResponse(fakeResponse);
            fakeContext.SetRequest(fakeRequest);
            return fakeContext;
        }