コード例 #1
0
        public void IndexView()
        {
            // Create simple view
            var viewPhysicalPath = testContextInstance.TestDir + @"\..\..\MvcApplication1\Views\Simple\Index.simple";
            var indexView        = new SimpleView(viewPhysicalPath);

            // Create view context
            var viewContext = new ViewContext();

            // Create view data
            var viewData = new ViewDataDictionary();

            viewData["message"]  = "Hello World!";
            viewContext.ViewData = viewData;

            // Render simple view
            var writer = new StringWriter();

            indexView.Render(viewContext, writer);

            // Assert
            StringAssert.Contains(writer.ToString(), "<h1>Hello World!</h1>");
        }