Beispiel #1
0
        public void ProcessResult_WhenRequestedWithModelUsingMaster_ReturnsCombinedView()
        {
            var response = new FakeResponseContext();
            var result = new SparkResult("../../Test Data/Views/Spark/Child.spark", "Master.spark");

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

            result.ProcessResult(null, response);

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

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

            result.ProcessResult(null, response);

            DateTime date;

            Assert.That(DateTime.TryParse(response.Response, out date));
        }
Beispiel #3
0
        public void ProcessResult_WhenRequestedWithModelUsingPartial_ReturnsCombinedView()
        {
            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("<span>partial</span>"));
        }
Beispiel #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 SparkResult("../../Test Data/Views/Spark/Url.spark");

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

            result.ProcessResult(null, response);

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

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

            result.ProcessResult(null, response);

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