Beispiel #1
0
        public void ActionWithGetOrPostOnlyAttributeCanBeInvokedWithGETAndPOST()
        {
            var controller = new AccThrController();

            var context = services.ControllerContextFactory.
                          Create("", "home", "GetAndPost", services.ControllerDescriptorProvider.BuildDescriptor(controller));

            request.HttpMethod = "GET";
            controller.Process(engineContext, context);
            Assert.AreEqual("home\\GetAndPost", engStubViewEngineManager.TemplateRendered);

            request.HttpMethod = "POST";
            controller.Process(engineContext, context);
            Assert.AreEqual("home\\GetAndPost", engStubViewEngineManager.TemplateRendered);
        }
		public void ActionWithGetOnlyAttributeCanBeInvokedWithGET()
		{
			AccThrController controller = new AccThrController();

			request.HttpMethod = "GET";

			IControllerContext context = services.ControllerContextFactory.
				Create("", "home", "GetOnly", services.ControllerDescriptorProvider.BuildDescriptor(controller));

			controller.Process(engineContext, context);

			Assert.AreEqual("home\\GetOnly", engStubViewEngineManager.TemplateRendered);
		}
		public void ActionWithGetOnlyAttributeCannotBeInvokedWithPOST()
		{
			AccThrController controller = new AccThrController();

			request.HttpMethod = "POST";

			IControllerContext context = services.ControllerContextFactory.
				Create("", "home", "GetOnly", services.ControllerDescriptorProvider.BuildDescriptor(controller));

			try
			{
				controller.Process(engineContext, context);
			}
			catch(Exception)
			{
				Assert.AreEqual(403, response.StatusCode);
				Assert.AreEqual("Forbidden", response.StatusDescription);

				throw;
			}
		}
Beispiel #4
0
        public void ActionWithPostOnlyAttributeCannotBeInvokedWithGET()
        {
            var controller = new AccThrController();

            request.HttpMethod = "GET";

            var context = services.ControllerContextFactory.
                          Create("", "home", "PostOnly", services.ControllerDescriptorProvider.BuildDescriptor(controller));

            try
            {
                controller.Process(engineContext, context);
            }
            catch (Exception)
            {
                Assert.AreEqual(403, response.StatusCode);
                Assert.AreEqual("Forbidden", response.StatusDescription);

                throw;
            }
        }