コード例 #1
0
        private string ExecuteClientSide(string testName, string templateFile, string dataFile)
        {
            var namingRule     = new NamingRule();
            var handlerFactory = new NullRenderingHelperHandlerFactory();

            var clientGenerator = new ClientTemplateGenerator(handlerFactory, new MemberLocatorFromNamingRule(namingRule));
            var generator       = new JavascriptClientTemplateGenerator("repo", clientGenerator);

            var templateInfo = new FileTemplateInfo(testName, PathInfo.Create(templateFile), new FileSystem());
            var view         = generator.Generate(templateInfo);

            Dictionary <string, object> model;

            using (var reader = new StreamReader(dataFile))
            {
                model = (Dictionary <string, object>) new JavaScriptSerializer().Deserialize(reader.ReadToEnd(), typeof(Dictionary <string, object>));
            }

            CleanupModel(model);

            this.TestContext.BeginTimer("JS Rendering");
            var result = JavascriptClientTest.ExecuteJavascript(view, model, testName);

            this.TestContext.EndTimer("JS Rendering");

            return(result);
        }
コード例 #2
0
        private static ClientTemplateGenerator CreateClientTemplateGenerator()
        {
            IMemberLocator memberLocator = new MemberLocatorFromNamingRule(new NamingRule());
            var helperHandlersMock = new Mock<IHelperHandlerFactory>();
            helperHandlersMock.Setup(f => f.Create()).Returns(Enumerable.Empty<IHelperHandler>());

            var generator = new ClientTemplateGenerator(helperHandlersMock.Object, memberLocator);
            return generator;
        }
コード例 #3
0
        private static ClientTemplateGenerator CreateClientTemplateGenerator()
        {
            IMemberLocator memberLocator      = new MemberLocatorFromNamingRule(new NamingRule());
            var            helperHandlersMock = new Mock <IHelperHandlerFactory>();

            helperHandlersMock.Setup(f => f.Create()).Returns(Enumerable.Empty <IHelperHandler>());

            var generator = new ClientTemplateGenerator(helperHandlersMock.Object, memberLocator);

            return(generator);
        }
コード例 #4
0
        private string ExecuteClientSide(string testName, string templateFile, string dataFile)
        {
            var namingRule = new NamingRule();
            var handlerFactory = new NullRenderingHelperHandlerFactory();

            var clientGenerator = new ClientTemplateGenerator(handlerFactory, new MemberLocatorFromNamingRule(namingRule));
            var generator = new JavascriptClientTemplateGenerator("repo", clientGenerator);

            var templateInfo = new FileTemplateInfo(testName, PathInfo.Create(templateFile), new FileSystem());
            var view = generator.Generate(templateInfo);

            Dictionary<string, object> model;
            using (var reader = new StreamReader(dataFile))
            {
                model = (Dictionary<string, object>) new JavaScriptSerializer().Deserialize(reader.ReadToEnd(), typeof(Dictionary<string, object>));
            }

            CleanupModel(model);

            var result = JavascriptClientTest.ExecuteJavascript(view, model, testName);
            return result;
        }