Exemple #1
0
        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()
				};

		}
Exemple #3
0
        public void RenderIncludes_ShouldWriteOutEachIncludeSeparately_WhenInDebugMode(RenderingInDebug data)
        {
            var stubContext = _mocks.Stub <HttpContextBase>();

            stubContext.Replay();
            stubContext.Expect(c => c.IsDebuggingEnabled).Return(true);
            _mockHttp.Expect(s => s.Context).Return(stubContext);
            foreach (var kvp in data.Includes)
            {
                _mockReader.Expect(sr => sr.ToAbsolute(kvp.Key)).Return(kvp.Value);
            }
            _mockStorage.Expect(s => s.Clear());
            string rendered = _combiner.RenderIncludes(data.Includes.Keys, data.Type, true);

            Assert.AreEqual(rendered, data.Expected);
        }
Exemple #4
0
 public void RenderIncludes_ShouldWriteOutEachIncludeSeparately_WhenInDebugMode(RenderingInDebug data)
 {
     var stubContext = _mocks.Stub<HttpContextBase>();
     stubContext.Replay();
     stubContext.Expect(c => c.IsDebuggingEnabled).Return(true);
     _mockHttp.Expect(s => s.Context).Return(stubContext);
     foreach (var kvp in data.Includes)
     {
         _mockReader.Expect(sr => sr.ToAbsolute(kvp.Key)).Return(kvp.Value);
     }
     _mockStorage.Expect(s => s.Clear());
     string rendered = _combiner.RenderIncludes(data.Includes.Keys, data.Type, true);
     Assert.AreEqual(rendered, data.Expected);
 }