Ejemplo n.º 1
0
        public void op_GetVirtualPath_RequestContext_RouteValueDictionary_whenInvalidDate()
        {
            var request = new Mock <HttpRequestBase>(MockBehavior.Strict);

            request
            .SetupGet(x => x.Path)
            .Returns("/1999-02-30")
            .Verifiable();

            var context = new Mock <HttpContextBase>(MockBehavior.Strict);

            context
            .SetupGet(x => x.Request)
            .Returns(request.Object)
            .Verifiable();

            var route = new DateRoute <DummyController>(string.Empty, "Representation");

            var actual = route.GetVirtualPath(
                new RequestContext(context.Object, new RouteData()),
                new RouteValueDictionary());

            Assert.Null(actual);

            request.VerifyAll();
        }
Ejemplo n.º 2
0
        public void op_GetRouteData_HttpContextBaseNull()
        {
            var route = new DateRoute <DummyController>(string.Empty, "Representation");

            // ReSharper disable AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => route.GetRouteData(null));

            // ReSharper restore AssignNullToNotNullAttribute
        }
Ejemplo n.º 3
0
        public void op_GetVirtualPath_RequestContextNull_RouteValueDictionary()
        {
            var route = new DateRoute <DummyController>(string.Empty, "Representation");

            // ReSharper disable AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => route.GetVirtualPath(null, new RouteValueDictionary()));

            // ReSharper restore AssignNullToNotNullAttribute
        }
Ejemplo n.º 4
0
        public void op_GetRouteData_HttpContextBase_whenNotFound()
        {
            var request = new Mock <HttpRequestBase>(MockBehavior.Strict);

            request
            .SetupGet(x => x.Path)
            .Returns("/example")
            .Verifiable();

            var context = new Mock <HttpContextBase>(MockBehavior.Strict);

            context
            .SetupGet(x => x.Request)
            .Returns(request.Object)
            .Verifiable();

            var route = new DateRoute <DummyController>(string.Empty, "Representation");

            var actual = route.GetRouteData(context.Object);

            Assert.Null(actual);

            request.VerifyAll();
        }
Ejemplo n.º 5
0
        public void op_GetRouteData_HttpContextBase()
        {
            var request = new Mock <HttpRequestBase>(MockBehavior.Strict);

            request
            .SetupGet(x => x.Path)
            .Returns("/1999-12-31")
            .Verifiable();
            request
            .SetupGet(x => x.AppRelativeCurrentExecutionFilePath).Returns("~/1999-12-31")
            .Verifiable();
            request
            .SetupGet(x => x.PathInfo)
            .Returns(string.Empty)
            .Verifiable();

            var context = new Mock <HttpContextBase>(MockBehavior.Strict);

            context
            .SetupGet(x => x.Request)
            .Returns(request.Object)
            .Verifiable();

            var route = new DateRoute <DummyController>(string.Empty, "Representation");

            var actual = route.GetRouteData(context.Object);

            // ReSharper disable PossibleNullReferenceException
            Assert.Equal("1999-12-31", (actual.Route as Route).Url);

            // ReSharper restore PossibleNullReferenceException
            Assert.Equal("Dummy", (string)actual.Values["controller"]);
            Assert.Equal("Representation", (string)actual.Values["action"]);

            request.VerifyAll();
        }