Пример #1
0
        public static FakeHttpContext FakeHttpContextWithCustomerAuthenticationSetTo(bool authenticated)
        {
            var fakeIdentity = MockRepository.GenerateStub<IIdentity>();
            fakeIdentity.Stub(x => x.IsAuthenticated).Return(authenticated);

            var fakePrincipal = MockRepository.GenerateStub<IPrincipal>();
            fakePrincipal.Stub(x => x.Identity).Return(fakeIdentity);

            var fakeContext = new FakeHttpContext("/",fakePrincipal,null,null,null,null);

            return fakeContext;
        }
Пример #2
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;
        }
Пример #3
0
 public static FakeHttpContext FakeHttpContextWithSession(SessionStateItemCollection sessionStateItem  )
 {
     var fakeContext = new FakeHttpContext("/",null,null,null,null,sessionStateItem);
     var fakeResponse = new FakeHttpResponseForCookieHandeling();
     fakeContext.SetResponse(fakeResponse);
     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;
        }