Exemple #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]);
        }
        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]);
        }
Exemple #3
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"]);
 }
Exemple #4
0
        public void CanSpecifyAppRelativeCurrentExecutionFilePath()
        {
            builder.AppRelativeCurrentExecutionFilePath = "someUrl";
            var testController = new TestHelperController();

            builder.InitializeController(testController);
            Assert.AreEqual("someUrl", testController.Request.AppRelativeCurrentExecutionFilePath);
        }
Exemple #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);
        }
Exemple #6
0
        public void CanSpecifyApplicationPath()
        {
            _builder.ApplicationPath = "someUrl";
            var testController = new TestHelperController();

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

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

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

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

            _builder.InitializeController(controller);
            Assert.AreEqual("Value", controller.HttpContext.Request.Form["Variable"]);
        }
Exemple #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"));
        }
Exemple #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"]);
        }
Exemple #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"));
        }
Exemple #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"]);
        }
Exemple #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"]);
        }
 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);
 }
 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"));
 }
        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"]);
        }
 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"));
 }
 public void CanSpecifyRawUrl()
 {
     builder.RawUrl = "someUrl";
     var testController = new TestHelperController();
     builder.InitializeController(testController);
     Assert.AreEqual("someUrl", testController.Request.RawUrl);
 }
 public void CanSpecifyQueryString()
 {
     builder.QueryString["Variable"] = "Value";
     var testController = new TestHelperController();
     builder.InitializeController(testController);
     Assert.AreEqual("Value", testController.Request.QueryString["Variable"]);
 }
        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"]);
        }
 public void CanSpecifyApplicationPath()
 {
     builder.ApplicationPath = "someUrl";
     var testController = new TestHelperController();
     builder.InitializeController(testController);
     Assert.AreEqual("someUrl", testController.Request.ApplicationPath);
 }
 public void CanSpecifyFormVariables()
 {
     builder.Form["Variable"] = "Value";
     var controller = new TestHelperController();
     builder.InitializeController(controller);
     Assert.AreEqual("Value", controller.HttpContext.Request.Form["Variable"]);
 }