public void RendersViewByDefault()
		{
			ControllerAndViews controller = new ControllerAndViews();

			IControllerContext context = services.ControllerContextFactory.
				Create("", "home", "EmptyAction", new ControllerMetaDescriptor());

			controller.Process(engineContext, context);

			Assert.AreEqual(200, response.StatusCode);
			Assert.AreEqual("OK", response.StatusDescription);
			Assert.AreEqual("home\\EmptyAction", engStubViewEngineManager.TemplateRendered);
		}
        public void ControllerCanOverrideView()
        {
            var controller = new ControllerAndViews();

            var context = services.ControllerContextFactory.
                          Create("", "home", "ActionWithViewOverride", new ControllerMetaDescriptor());

            controller.Process(engineContext, context);

            Assert.AreEqual(200, response.StatusCode);
            Assert.AreEqual("OK", response.StatusDescription);
            Assert.AreEqual("home\\SomethingElse", engStubViewEngineManager.TemplateRendered);
        }
        public void RendersViewByDefault()
        {
            var controller = new ControllerAndViews();

            var context = services.ControllerContextFactory.
                          Create("", "home", "EmptyAction", new ControllerMetaDescriptor());

            controller.Process(engineContext, context);

            Assert.AreEqual(200, response.StatusCode);
            Assert.AreEqual("OK", response.StatusDescription);
            Assert.AreEqual("home\\EmptyAction", engStubViewEngineManager.TemplateRendered);
        }
Exemplo n.º 4
0
		public void RendersInferredViewIfTemplateExists()
		{
			var controller = new ControllerAndViews();

			var context = services.ControllerContextFactory.
				Create("", "home", "InferredAction", new ControllerMetaDescriptor());

			engStubViewEngineManager.RegisterTemplate("home\\InferredAction");

			controller.Process(engineContext, context);

			Assert.AreEqual(200, response.StatusCode);
			Assert.AreEqual("OK", response.StatusDescription);
			Assert.AreEqual("home\\InferredAction", engStubViewEngineManager.TemplateRendered);
		}
        public void RendersInferredViewIfTemplateExists()
        {
            var controller = new ControllerAndViews();

            var context = services.ControllerContextFactory.
                          Create("", "home", "InferredAction", new ControllerMetaDescriptor());

            engStubViewEngineManager.RegisterTemplate("home\\InferredAction");

            controller.Process(engineContext, context);

            Assert.AreEqual(200, response.StatusCode);
            Assert.AreEqual("OK", response.StatusDescription);
            Assert.AreEqual("home\\InferredAction", engStubViewEngineManager.TemplateRendered);
        }
        public void RendersInferredView_IfTemplateDoesNotExistsResultsIn404()
        {
            var controller = new ControllerAndViews();

            var context = services.ControllerContextFactory.
                          Create("", "home", "InferredAction", new ControllerMetaDescriptor());

            try
            {
                controller.Process(engineContext, context);
                Assert.Fail("Should have thrown a 404.");
            }
            catch (HttpException)
            {
                Assert.AreEqual(404, response.StatusCode);
            }
        }
Exemplo n.º 7
0
		public void InvokingNonExistingActionResultsIn404()
		{
			var controller = new ControllerAndViews();

			var context = new DefaultControllerContextFactory().
				Create("", "home", "NonExistentAction", new ControllerMetaDescriptor());

			try
			{
				controller.Process(engineContext, context);
			}
			catch(MonoRailException)
			{
				Assert.AreEqual(404, response.StatusCode);

				throw;
			}
		}
        public void InvokingNonExistingActionResultsIn404()
        {
            var controller = new ControllerAndViews();

            var context = new DefaultControllerContextFactory().
                          Create("", "home", "NonExistentAction", new ControllerMetaDescriptor());

            try
            {
                controller.Process(engineContext, context);
            }
            catch (MonoRailException)
            {
                Assert.AreEqual(404, response.StatusCode);

                throw;
            }
        }
Exemplo n.º 9
0
		public void RendersInferredView_IfTemplateDoesNotExistsResultsIn404()
		{
			var controller = new ControllerAndViews();

			var context = services.ControllerContextFactory.
				Create("", "home", "InferredAction", new ControllerMetaDescriptor());

			try
			{
				controller.Process(engineContext, context);
				Assert.Fail("Should have thrown a 404.");
			}
			catch (HttpException)
			{
				Assert.AreEqual(404, response.StatusCode);
			}
		}
Exemplo n.º 10
0
		public void ControllerCanCancelView()
		{
			var controller = new ControllerAndViews();

			var context = services.ControllerContextFactory.
				Create("", "home", "CancelsTheView", new ControllerMetaDescriptor());

			controller.Process(engineContext, context);

			Assert.AreEqual(200, response.StatusCode);
			Assert.AreEqual("OK", response.StatusDescription);
			Assert.IsNull(engStubViewEngineManager.TemplateRendered);
		}
Exemplo n.º 11
0
		public void ControllerCanOverrideView()
		{
			var controller = new ControllerAndViews();

			var context = services.ControllerContextFactory.
				Create("", "home", "ActionWithViewOverride", new ControllerMetaDescriptor());

			controller.Process(engineContext, context);

			Assert.AreEqual(200, response.StatusCode);
			Assert.AreEqual("OK", response.StatusDescription);
			Assert.AreEqual("home\\SomethingElse", engStubViewEngineManager.TemplateRendered);
		}