Inheritance: IResponseContext
Example #1
0
        public void ProcessResult_WhenRequestedWithModelUsingMaster_ReturnsCombinedView()
        {
            var response = new FakeResponseContext();
            var result = new RazorResult("../../Test Data/Views/Razor/Child.cshtml", "Master.cshtml");

            Assert.That(result.ViewPath, Is.EqualTo("../../Test Data/Views/Razor/Child.cshtml"));
            Assert.That(result.MasterPath, Is.EqualTo("Master.cshtml"));

            result.ProcessResult(null, response);

            Assert.That(response.ContentType, Is.EqualTo("text/html"));
            Assert.That(response.Response, Contains.Substring("<h1>hello world</h1>"));
        }
Example #2
0
        public void ProcessResult_WhenOutputtingDateTime_IsAbleToAccessSystemNamespace()
        {
            var response = new FakeResponseContext();
            var result = new RazorResult("../../Test Data/Views/Razor/DateTime.cshtml");

            Assert.That(result.ViewPath, Is.EqualTo("../../Test Data/Views/Razor/DateTime.cshtml"));

            result.ProcessResult(null, response);

            DateTime date;

            Assert.That(DateTime.TryParse(response.Response, out date));
        }
Example #3
0
        public void ProcessResult_WhenRequestedWithModelUsingPartial_ReturnsCombinedView()
        {
            var response = new FakeResponseContext();
            var model = new UserModel { ID = 42, Username = "******" };
            var result = new RazorResult<UserModel>(model, "../../Test Data/Views/Razor/View.cshtml");

            Assert.That(result.ViewPath, Is.EqualTo("../../Test Data/Views/Razor/View.cshtml"));
            Assert.That(result.Model.ID, Is.EqualTo(42));
            Assert.That(result.Model.Username, Is.EqualTo("Username"));

            result.ProcessResult(null, response);

            Assert.That(response.ContentType, Is.EqualTo("text/html"));
            Assert.That(response.Response, Contains.Substring("<span>partial</span>"));
        }
Example #4
0
        public void ProcessResult_WhenOutputtingHandlerUrl_IsAbleToAccessTinywebHandlersNamespace()
        {
            Tinyweb.Handlers = new List<HandlerData>
            {
                new HandlerData { Uri = "foo/bar", Type = typeof(TestHandler) }
            };

            Url.ApplicationPathProvider = new FakeApplicationPathProvider();

            var response = new FakeResponseContext();
            var result = new RazorResult("../../Test Data/Views/Razor/Url.cshtml");

            Assert.That(result.ViewPath, Is.EqualTo("../../Test Data/Views/Razor/Url.cshtml"));

            result.ProcessResult(null, response);

            Assert.That(response.Response, Is.EqualTo("/foo/bar?key=value"));
        }
Example #5
0
        public void ProcessResult_WhenRequestedWithNoModel_ReturnsViewData()
        {
            var response = new FakeResponseContext();
            var result = new RazorResult("../../Test Data/Views/Razor/Simple.cshtml");

            Assert.That(result.ViewPath, Is.EqualTo("../../Test Data/Views/Razor/Simple.cshtml"));

            result.ProcessResult(null, response);

            Assert.That(response.ContentType, Is.EqualTo("text/html"));
            Assert.That(response.Response, Contains.Substring("<h1>header</h1>"));
        }
Example #6
0
        public void ProcessResult_WhenRequestedWithModel_ReturnsViewData()
        {
            var response = new FakeResponseContext();
            var model = new UserModel { ID = 42, Username = "******" };
            var result = new SparkResult<UserModel>(model, "../../Test Data/Views/Spark/View.spark");

            Assert.That(result.ViewPath, Is.EqualTo("../../Test Data/Views/Spark/View.spark"));
            Assert.That(result.Model.ID, Is.EqualTo(42));
            Assert.That(result.Model.Username, Is.EqualTo("Username"));

            result.ProcessResult(null, response);

            Assert.That(response.ContentType, Is.EqualTo("text/html"));
            Assert.That(response.Response, Contains.Substring("<h1>42</h1>"));
            Assert.That(response.Response, Contains.Substring("<h2>Username</h2>"));
        }