public IncludeCombinerStateTester() { CssInDebug = new RenderingInDebug { Includes = new Dictionary <string, string> { { "/foo.css", "/foo.css" }, { "/bar.css", "/bar.css" } }, Type = IncludeType.Css, Expected = string.Format("<link rel='stylesheet' type='text/css' href='/foo.css'/>{0}<link rel='stylesheet' type='text/css' href='/bar.css'/>{0}", Environment.NewLine) }; ScriptInDebug = new RenderingInDebug { Includes = new Dictionary <string, string> { { "/foo.js", "/foo.js" }, { "/bar.js", "/bar.js" } }, Type = IncludeType.Js, Expected = string.Format("<script type='text/javascript' src='/foo.js'></script>{0}<script type='text/javascript' src='/bar.js'></script>{0}", Environment.NewLine) }; ScriptWithPath = new RenderingInDebug { Includes = new Dictionary <string, string> { { "~/content/js/foo.js", "/content/js/foo.js" }, { "/bar.js", "/bar.js" } }, Type = IncludeType.Js, Expected = string.Format("<script type='text/javascript' src='/content/js/foo.js'></script>{0}<script type='text/javascript' src='/bar.js'></script>{0}", Environment.NewLine) }; ScriptInRelease = new RenderingInRelease { Includes = new Dictionary <string, string> { { "~/content/js/foo.js", "/content/js/foo.js" }, { "/bar.js", "/bar.js" } }, Type = IncludeType.Js, Key = "hashed", Expected = "<script type='text/javascript' src='/content/js/hashed.js'></script>", Settings = new JsTypeElement() }; CssInRelease = new RenderingInRelease { Includes = new Dictionary <string, string> { { "~/content/css/foo.css", "/content/css/foo.css" }, { "/bar.css", "/bar.css" } }, Type = IncludeType.Css, Key = "hashed==", Expected = "<link rel='stylesheet' type='text/css' href='/content/css/hashed==.css'/>", Settings = new CssTypeElement() }; CssInReleaseWithArseyUrl = new RenderingInRelease { Includes = new Dictionary <string, string> { { "~/content/css/foo.css", "/content/css/foo.css" }, { "/bar.css", "/bar.css" } }, Type = IncludeType.Css, Key = "really/nasty%20url=", Expected = "<link rel='stylesheet' type='text/css' href='/content/css/really/nasty%20url=.css'/>", Settings = new CssTypeElement() }; }
public IncludeCombinerStateTester() { CssInDebug = new RenderingInDebug { Includes = new Dictionary<string, string> { { "/foo.css", "/foo.css" }, { "/bar.css", "/bar.css" } }, Type = IncludeType.Css, Expected = string.Format("<link rel='stylesheet' type='text/css' href='/foo.css'/>{0}<link rel='stylesheet' type='text/css' href='/bar.css'/>{0}", Environment.NewLine) }; ScriptInDebug = new RenderingInDebug { Includes = new Dictionary<string, string> { { "/foo.js", "/foo.js" }, { "/bar.js", "/bar.js" } }, Type = IncludeType.Js, Expected = string.Format("<script type='text/javascript' src='/foo.js'></script>{0}<script type='text/javascript' src='/bar.js'></script>{0}", Environment.NewLine) }; ScriptWithPath = new RenderingInDebug { Includes = new Dictionary<string, string> { { "~/content/js/foo.js", "/content/js/foo.js" }, { "/bar.js", "/bar.js" } }, Type = IncludeType.Js, Expected = string.Format("<script type='text/javascript' src='/content/js/foo.js'></script>{0}<script type='text/javascript' src='/bar.js'></script>{0}", Environment.NewLine) }; ScriptInRelease = new RenderingInRelease { Includes = new Dictionary<string, string> { { "~/content/js/foo.js", "/content/js/foo.js" }, { "/bar.js", "/bar.js" } }, Type = IncludeType.Js, Key = "hashed", Expected = "<script type='text/javascript' src='/content/js/hashed.js'></script>", Settings = new JsTypeElement() }; CssInRelease = new RenderingInRelease { Includes = new Dictionary<string, string> { { "~/content/css/foo.css", "/content/css/foo.css" }, { "/bar.css", "/bar.css" } }, Type = IncludeType.Css, Key = "hashed==", Expected = "<link rel='stylesheet' type='text/css' href='/content/css/hashed==.css'/>", Settings = new CssTypeElement() }; CssInReleaseWithArseyUrl = new RenderingInRelease { Includes = new Dictionary<string, string> { { "~/content/css/foo.css", "/content/css/foo.css" }, { "/bar.css", "/bar.css" } }, Type = IncludeType.Css, Key = "really/nasty%20url=", Expected = "<link rel='stylesheet' type='text/css' href='/content/css/really/nasty%20url=.css'/>", Settings = new CssTypeElement() }; }
public void RenderIncludes_ShouldWriteOutASingleReferenceToTheCompressorController_WhenInReleaseMode(RenderingInRelease data) { var stubContext = _mocks.Stub <HttpContextBase>(); stubContext.Replay(); stubContext.Expect(c => c.IsDebuggingEnabled).Return(false); _mockHttp.Expect(s => s.Context).Return(stubContext); _mockSettings.Expect(s => s.Types[data.Type]).Return(data.Settings); foreach (var kvp in data.Includes) { var include = new Include(data.Type, kvp.Key, "foo", DateTime.UtcNow); _mockReader.Expect(r => r.Read(kvp.Key, data.Type)).Return(include); _mockStorage.Expect(s => s.Store(include)); } _mockReader.Expect(r => r.ToAbsolute(Arg <string> .Is.NotNull)).Return(string.Format("/content/{0}/{1}.{0}", data.Type.ToString().ToLowerInvariant(), data.Key)); string hash = null; _mockStorage.Expect(s => hash = s.Store(Arg <IncludeCombination> .Is.NotNull)).Return("foo"); string reference = _combiner.RenderIncludes(data.Includes.Keys, data.Type, false); Assert.AreEqual(data.Expected, reference); }
public void RenderIncludes_ShouldWriteOutASingleReferenceToTheCompressorController_WhenInReleaseMode(RenderingInRelease data) { var stubContext = _mocks.Stub<HttpContextBase>(); stubContext.Replay(); stubContext.Expect(c => c.IsDebuggingEnabled).Return(false); _mockHttp.Expect(s => s.Context).Return(stubContext); _mockSettings.Expect(s => s.Types[data.Type]).Return(data.Settings); foreach (var kvp in data.Includes) { var include = new Include(data.Type, kvp.Key, "foo", DateTime.UtcNow); _mockReader.Expect(r => r.Read(kvp.Key, data.Type)).Return(include); _mockStorage.Expect(s => s.Store(include)); } _mockReader.Expect(r => r.ToAbsolute(Arg<string>.Is.NotNull)).Return(string.Format("/content/{0}/{1}.{0}", data.Type.ToString().ToLowerInvariant(), data.Key)); string hash = null; _mockStorage.Expect(s => hash = s.Store(Arg<IncludeCombination>.Is.NotNull)).Return("foo"); string reference = _combiner.RenderIncludes(data.Includes.Keys, data.Type, false); Assert.AreEqual(data.Expected, reference); }