Ejemplo n.º 1
0
        public static void ResetCookies()
        {
            // Arrange
            var requestCookies = new HttpCookieCollection();

            requestCookies.Add(new HttpCookie("x1"));
            requestCookies.Add(new HttpCookie("x2"));
            var responseCookies = new HttpCookieCollection();
            var context         = MockHttpFactory.GetHttpContext();

            context.Setup(c => c.Request.Cookies).Returns(requestCookies);
            context.Setup(c => c.Response.Cookies).Returns(responseCookies);
            var request  = context.Object.Request;
            var response = context.Object.Response;

            // Act
            CookieHelper.ResetCookies(context.Object);

            // Assert
            Assert.Equal(0, request.Cookies.Count);
            Assert.Equal(2, response.Cookies.Count);

            var x1 = response.Cookies[0];

            Assert.Equal("x1", x1.Name);
            Assert.True(x1.Expires <= DateTime.UtcNow.AddYears(-1));
            var x2 = response.Cookies[1];

            Assert.Equal("x2", x2.Name);
            Assert.True(x2.Expires <= DateTime.UtcNow.AddYears(-1));
        }
Ejemplo n.º 2
0
 public SchemeRouteConstraintTest()
 {
     m_mockHttpContext = MockHttpFactory.GetHttpContext();
     m_constraint      = new SchemeRouteConstraint();
     m_variables       = new NameValueCollection();
     m_variables.Add("X_FORWARDED_PROTO", "https");
 }
Ejemplo n.º 3
0
        public ControllerFactoryTest()
        {
            m_resolverMock = new Mock <IoC::IDependencyResolver>(MockBehavior.Strict);
            m_resolverMock.Setup(resolver => resolver.Dispose());
            IoC::DependencyResolver.InitializeWith(m_resolverMock.Object);
            var mockHttpContext = MockHttpFactory.GetHttpContext();

            m_factory = new MockControllerFactory();
            m_factory.RequestContext = new RequestContext(mockHttpContext.Object, new RouteData());
        }
Ejemplo n.º 4
0
        public SubstitutionHelperTest()
        {
            if (!g_substitutionAdded)
            {
                HttpResponseSubstitutionHandler.Add("name", (c, s) => "result");
                g_substitutionAdded = true;
            }

            m_mockContext = MockHttpFactory.GetHttpContext();
            m_htmlHelper  = MockHttpFactory.GetHtmlHelper(m_mockContext.Object);
        }
Ejemplo n.º 5
0
 public AjaxRedirectHelperTest()
 {
     m_mockHttpContext = MockHttpFactory.GetHttpContext();
 }
Ejemplo n.º 6
0
 public DomainRouteConstraintTest()
 {
     m_mockHttpContext = MockHttpFactory.GetHttpContext();
     m_constraint      = new DomainRouteConstraint();
 }
Ejemplo n.º 7
0
 public UrlHelperExtensionsTest()
 {
     m_mockHttpContext = MockHttpFactory.GetHttpContext();
 }
Ejemplo n.º 8
0
 public HttpResponseSubstitutionRouteHandlerTest()
 {
     m_mockContext = MockHttpFactory.GetHttpContext();
 }