Пример #1
0
        public void ExportsCorrectJson()
        {
            var pageConfig = new PageConfig("http://www.test.com/", "http://www.test.com/Virtual", Assembly.GetExecutingAssembly());

            var json = pageConfig.Json;

            var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            version = version.Substring(0, version.LastIndexOf('.'));

            var expected = HttpUtility.HtmlEncode($"{{\"originUrl\":\"http://www.test.com/\",\"rootUrl\":\"http://www.test.com/Virtual\",\"version\":\"{version}\"}}");

            Assert.AreEqual(expected, json);
        }
Пример #2
0
        public void ExportsCorrectJavascript()
        {
            var pageConfig = new PageConfig("http://www.test.com/", "http://www.test.com/Virtual", Assembly.GetExecutingAssembly());

            var javascript = pageConfig.ToJavascript();

            var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            version = version.Substring(0, version.LastIndexOf('.'));

            var expected = "(function(){" +
                           "if(!window.hasOwnProperty(\"page\")) window.page={};" +
                           "window.page.config={" +
                           "originUrl:\"http://www.test.com/\"," +
                           "rootUrl:\"http://www.test.com/Virtual\"," +
                           $"version:\"{version}\"" +
                           "};})();";

            Assert.AreEqual(expected, javascript);
        }