public async Task render_template_with_embedded_layout()
        {
            var cts  = new CancellationTokenSource();
            var view = new ViewResult(_request, "Test2", new { Name = "foo" });

            var response = await view.ExecuteAsync(cts.Token);

            var output = await response.Content.ReadAsStringAsync();

            Assert.AreEqual("<html>Hello foo! Welcome to Razor!</html>", output);
        }
        public async Task render_simple_template_with_no_model()
        {
            var cts  = new CancellationTokenSource();
            var view = new ViewResult(_request, "TestNull", null);

            var response = await view.ExecuteAsync(cts.Token);

            var output = await response.Content.ReadAsStringAsync();

            Assert.AreEqual("Hello foo! Welcome to Razor!", output);
        }
        public async Task render_template_with_specified_resolver()
        {
            var cts       = new CancellationTokenSource();
            var resolver  = new EmbeddedResolver(this.GetType());
            var formatter = new HtmlMediaTypeViewFormatter(null, new RazorViewLocator(), new RazorViewParser(resolver));

            // Replace the HTML formatter.
            var config       = _request.GetConfiguration();
            var oldFormatter = config.Formatters.GetHtmlFormatter();

            config.Formatters.Remove(oldFormatter);
            config.Formatters.Add(formatter);

            var view = new ViewResult(_request, "Test2", new { Name = "foo" });

            var response = await view.ExecuteAsync(cts.Token);

            var output = await response.Content.ReadAsStringAsync();

            Assert.AreEqual("<html>Hello foo! Welcome to Razor!</html>", output);
        }