Ejemplo n.º 1
0
        public async Task <JavaScriptResult> ServerVariables()
        {
            // cache the result if debugging is disabled
            var serverVars = await _serverVariables.ParseAsync(await _backOfficeServerVariables.GetServerVariablesAsync());

            var result = _hostingEnvironment.IsDebugMode
                ? serverVars
                : _appCaches.RuntimeCache.GetCacheItem <string>(
                typeof(BackOfficeController) + "ServerVariables",
                () => serverVars,
                new TimeSpan(0, 10, 0));

            return(new JavaScriptResult(result));
        }
    public async Task Parse()
    {
        var parser = new ServerVariablesParser(Mock.Of <IEventAggregator>());

        var d = new Dictionary <string, object>
        {
            { "test1", "Test 1" },
            { "test2", "Test 2" },
            { "test3", "Test 3" },
            { "test4", "Test 4" },
            { "test5", "Test 5" },
        };

        var output = (await parser.ParseAsync(d)).StripWhitespace();

        Assert.IsTrue(output.Contains(@"Umbraco.Sys.ServerVariables = {
  ""test1"": ""Test 1"",
  ""test2"": ""Test 2"",
  ""test3"": ""Test 3"",
  ""test4"": ""Test 4"",
  ""test5"": ""Test 5""
} ;".StripWhitespace()));
    }