コード例 #1
0
        public void CacheIsAvailable()
        {
            var builder = new TestControllerBuilder();

            Assert.IsNotNull(builder.HttpContext.Cache);

            var controller = new TestHelperController();

            builder.InitializeController(controller);

            Assert.IsNotNull(controller.HttpContext.Cache);

            string testKey   = "TestKey";
            string testValue = "TestValue";

            controller.HttpContext.Cache.Add(testKey,
                                             testValue,
                                             null,
                                             DateTime.Now.AddSeconds(1),
                                             Cache.NoSlidingExpiration,
                                             CacheItemPriority.Normal,
                                             null);

            Assert.AreEqual(testValue,
                            controller.HttpContext.Cache[testKey]);
        }
コード例 #2
0
        public void CacheIsAvailable()
        {
            var builder = new TestControllerBuilder();

            Assert.IsNotNull(builder.HttpContext.Cache);

            var controller = new TestHelperController();
            builder.InitializeController(controller);

            Assert.IsNotNull(controller.HttpContext.Cache);

            string testKey = "TestKey";
            string testValue = "TestValue";

            controller.HttpContext.Cache.Add(testKey,
                                             testValue,
                                             null,
                                             DateTime.Now.AddSeconds(1),
                                             Cache.NoSlidingExpiration,
                                             CacheItemPriority.Normal,
                                             null);

            Assert.AreEqual(testValue,
                            controller.HttpContext.Cache[testKey]);
        }
コード例 #3
0
ファイル: SessionTests.cs プロジェクト: JonKruger/MvcContrib
 public void CanSpecifySessionVariables()
 {
     var builder = new TestControllerBuilder();
     builder.Session["Variable"] = "Value";
     var testHelperController = new TestHelperController();
     builder.InitializeController(testHelperController);
     Assert.AreEqual("Value", testHelperController.HttpContext.Session["Variable"]);
 }
コード例 #4
0
        public void CanSpecifyAppRelativeCurrentExecutionFilePath()
        {
            builder.AppRelativeCurrentExecutionFilePath = "someUrl";
            var testController = new TestHelperController();

            builder.InitializeController(testController);
            Assert.AreEqual("someUrl", testController.Request.AppRelativeCurrentExecutionFilePath);
        }
コード例 #5
0
        public void When_response_status_is_set_it_should_persist()
        {
            var testController = new TestHelperController();

            _builder.InitializeController(testController);
            testController.HttpContext.Response.Status = "404 Not Found";
            Assert.AreEqual("404 Not Found", testController.HttpContext.Response.Status);
        }
コード例 #6
0
        public void CanSpecifyApplicationPath()
        {
            _builder.ApplicationPath = "someUrl";
            var testController = new TestHelperController();

            _builder.InitializeController(testController);
            Assert.AreEqual("someUrl", testController.Request.ApplicationPath);
        }
コード例 #7
0
        public void CanSpecifyRawUrl()
        {
            builder.RawUrl = "someUrl";
            var testController = new TestHelperController();

            builder.InitializeController(testController);
            Assert.AreEqual("someUrl", testController.Request.RawUrl);
        }
コード例 #8
0
        public void CanSpecifyQueryString()
        {
            _builder.QueryString["Variable"] = "Value";
            var testController = new TestHelperController();

            _builder.InitializeController(testController);
            Assert.AreEqual("Value", testController.Request.QueryString["Variable"]);
        }
コード例 #9
0
        public void CanSpecifyPathInfol()
        {
            _builder.PathInfo = "someUrl";
            var testController = new TestHelperController();

            _builder.InitializeController(testController);
            Assert.AreEqual("someUrl", testController.Request.PathInfo);
        }
コード例 #10
0
        public void CanSpecifyFormVariables()
        {
            _builder.Form["Variable"] = "Value";
            var controller = new TestHelperController();

            _builder.InitializeController(controller);
            Assert.AreEqual("Value", controller.HttpContext.Request.Form["Variable"]);
        }
コード例 #11
0
        public void CanSpecifyRequestAcceptTypes()
        {
            _builder.AcceptTypes = new[] { "some/type-extension" };
            var controller = new TestHelperController();

            _builder.InitializeController(controller);
            Assert.That(controller.HttpContext.Request.AcceptTypes, Is.Not.Null);
            Assert.That(controller.HttpContext.Request.AcceptTypes.Length, Is.EqualTo(1));
            Assert.That(controller.HttpContext.Request.AcceptTypes[0], Is.EqualTo("some/type-extension"));
        }
コード例 #12
0
        public void CanSpecifySessionVariables()
        {
            var builder = new TestControllerBuilder();

            builder.Session["Variable"] = "Value";
            var testHelperController = new TestHelperController();

            builder.InitializeController(testHelperController);
            Assert.AreEqual("Value", testHelperController.HttpContext.Session["Variable"]);
        }
コード例 #13
0
        public void When_params_is_invoked_it_should_return_a_combination_of_form_and_querystring()
        {
            _builder.QueryString["foo"] = "bar";
            _builder.Form["baz"]        = "blah";
            var testController = new TestHelperController();

            _builder.InitializeController(testController);
            Assert.That(testController.Request.Params["foo"], Is.EqualTo("bar"));
            Assert.That(testController.Request.Params["baz"], Is.EqualTo("blah"));
        }
コード例 #14
0
        public void CanSpecifyFiles()
        {
            var mocks = new MockRepository();
            var file  = mocks.DynamicMock <HttpPostedFileBase>();

            _builder.Files["Variable"] = file;
            var controller = new TestHelperController();

            _builder.InitializeController(controller);
            Assert.AreSame(file, controller.Request.Files["Variable"]);
        }
コード例 #15
0
        public void CanSpecifyRouteData()
        {
            var rd = new RouteData();

            rd.Values["Variable"] = "Value";
            _builder.RouteData    = rd;

            var controller = new TestHelperController();

            _builder.InitializeController(controller);
            Assert.AreEqual("Value", controller.RouteData.Values["Variable"]);
        }
コード例 #16
0
 public void When_response_status_is_set_it_should_persist()
 {
     var testController = new TestHelperController();
     builder.InitializeController(testController);
     testController.HttpContext.Response.Status = "404 Not Found";
     Assert.AreEqual("404 Not Found", testController.HttpContext.Response.Status);
 }
コード例 #17
0
 public void When_params_is_invoked_it_should_return_a_combination_of_form_and_querystring()
 {
     builder.QueryString["foo"] = "bar";
     builder.Form["baz"] = "blah";
     var testController = new TestHelperController();
     builder.InitializeController(testController);
     Assert.That(testController.Request.Params["foo"], Is.EqualTo("bar"));
     Assert.That(testController.Request.Params["baz"], Is.EqualTo("blah"));
 }
コード例 #18
0
        public void CanSpecifyRouteData()
        {
            var rd = new RouteData();
            rd.Values["Variable"] = "Value";
            builder.RouteData = rd;

            var controller = new TestHelperController();
            builder.InitializeController(controller);
            Assert.AreEqual("Value", controller.RouteData.Values["Variable"]);
        }
コード例 #19
0
 public void CanSpecifyRequestAcceptTypes()
 {
     builder.AcceptTypes = new[] {"some/type-extension"};
     var controller = new TestHelperController();
     builder.InitializeController(controller);
     Assert.That(controller.HttpContext.Request.AcceptTypes, Is.Not.Null);
     Assert.That(controller.HttpContext.Request.AcceptTypes.Length, Is.EqualTo(1));
     Assert.That(controller.HttpContext.Request.AcceptTypes[0], Is.EqualTo("some/type-extension"));
 }
コード例 #20
0
 public void CanSpecifyRawUrl()
 {
     builder.RawUrl = "someUrl";
     var testController = new TestHelperController();
     builder.InitializeController(testController);
     Assert.AreEqual("someUrl", testController.Request.RawUrl);
 }
コード例 #21
0
 public void CanSpecifyQueryString()
 {
     builder.QueryString["Variable"] = "Value";
     var testController = new TestHelperController();
     builder.InitializeController(testController);
     Assert.AreEqual("Value", testController.Request.QueryString["Variable"]);
 }
コード例 #22
0
        public void CanSpecifyFiles()
        {
            var mocks = new MockRepository();
            var file = mocks.DynamicMock<HttpPostedFileBase>();

            builder.Files["Variable"] = file;
            var controller = new TestHelperController();
            builder.InitializeController(controller);
            Assert.AreSame(file, controller.Request.Files["Variable"]);
        }
コード例 #23
0
 public void CanSpecifyApplicationPath()
 {
     builder.ApplicationPath = "someUrl";
     var testController = new TestHelperController();
     builder.InitializeController(testController);
     Assert.AreEqual("someUrl", testController.Request.ApplicationPath);
 }
コード例 #24
0
 public void CanSpecifyFormVariables()
 {
     builder.Form["Variable"] = "Value";
     var controller = new TestHelperController();
     builder.InitializeController(controller);
     Assert.AreEqual("Value", controller.HttpContext.Request.Form["Variable"]);
 }