Esempio n. 1
0
        public void ViewResultShouldSupportOverridenStatusCode()
        {
            ICompiledRazorTemplate template = MockRepository.GenerateMock <ICompiledRazorTemplate>();

            template.Expect(x => x.Execute(null)).IgnoreArguments().Return("rendered view");

            viewRenderingEngine.Expect(x => x.GetViewTemplateByName("SomeModel")).Return(template);

            SampleViewModel model = new SampleViewModel();
            ViewResult <SampleViewModel> result = new ViewResult <SampleViewModel>("SomeModel", model, razorEngineExecutionSettings);

            result.StatusCode = (int)HttpStatusCode.NotFound;
            result.Apply(context);

            Assert.AreEqual((int)HttpStatusCode.NotFound, context.StatusCode);
        }
Esempio n. 2
0
        public void RenderViewByName()
        {
            ICompiledRazorTemplate template = MockRepository.GenerateMock <ICompiledRazorTemplate>();

            template.Expect(x => x.Execute(null)).IgnoreArguments().Return("rendered view");

            viewRenderingEngine.Expect(x => x.GetViewTemplateByName("SomeModel")).Return(template);

            SampleViewModel model = new SampleViewModel();
            ViewResult <SampleViewModel> result = new ViewResult <SampleViewModel>("SomeModel", model, razorEngineExecutionSettings);

            result.Apply(context);

            viewRenderingEngine.VerifyAllExpectations();
            template.VerifyAllExpectations();
        }