Example #1
0
        public void LocalScriptGroupAddTest()
        {
            var scriptGroup = new LocalScriptGroup();

            var path    = "path/to/script";
            var script1 = new LinkedScript(path);
            var script2 = new LinkedScript(path);

            scriptGroup.Add(script1);

            try
            {
                scriptGroup.Add(script2);
            }
            catch (ResourceAlreadyAddedException)
            {
                return;
            }
            catch (Exception)
            {
                Assert.Fail("Incorrect exception thrown.");
            }

            Assert.Fail("No exception thrown.");
        }
Example #2
0
        public void LocalScriptGroupRegisterTest2()
        {
            var scriptGroup = new LocalScriptGroup {
                Helper = new MockLocalHelper()
            };

            var script1 = "~/Scripts/Script1.js";
            var script2 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/Scripts/Script1.js";

            scriptGroup.Register(script1, script2);

            Assert.AreEqual(1, scriptGroup.Count);
        }
Example #3
0
        public void LocalScriptGroupRegisterTest()
        {
            var scriptGroup = new LocalScriptGroup();

            var path    = "path/to/script";
            var script1 = new LinkedScript(path);
            var script2 = new LinkedScript(path);

            scriptGroup.Register(script1);
            scriptGroup.Register(script2);

            Assert.AreEqual(1, scriptGroup.Count);
        }
Example #4
0
        public void LocalScriptGroupHasRegisteredTest()
        {
            var scriptGroup = new LocalScriptGroup();

            var path    = "path/to/script";
            var script1 = new LinkedScript(path);
            var script2 = new LinkedScript(path);

            Assert.IsFalse(scriptGroup.HasRegistered(script1));
            Assert.IsFalse(scriptGroup.HasRegistered(script2));

            scriptGroup.Register(script1);

            Assert.IsTrue(scriptGroup.HasRegistered(script1));
            Assert.IsTrue(scriptGroup.HasRegistered(script2));
        }
Example #5
0
        public void LocalScriptGroupRenderTest()
        {
            var scriptGroup = new LocalScriptGroup();

            var path1   = "path/to/script1";
            var path2   = "path/to/script2";
            var script1 = new LinkedScript(path1);
            var script2 = new LinkedScript(path2);

            scriptGroup.Add(script1);
            scriptGroup.Add(script2);

            Func <string, string> renderTest = s => "<script type=\"text/javascript\" src=\"" + s + "\"></script>";

            var render   = scriptGroup.Render();
            var expected = renderTest(path1) + Environment.NewLine + renderTest(path2);

            Assert.AreEqual(expected, render);
        }
Example #6
0
        public void LocalScriptGroupRegisterTest3()
        {
            var scriptGroup = new LocalScriptGroup {
                Helper = new MockLocalHelper()
            };

            var script = "~/Scripts/DoesNotExist.js";

            try
            {
                scriptGroup.Register(script);
            }
            catch (ResourceNotFoundException)
            {
                return;
            }
            catch (Exception)
            {
                Assert.Fail("Wrong exception thrown.");
            }

            Assert.Fail("No exception thrown.");
        }
Example #7
0
        public void LocalScriptGroupConstructorTest()
        {
            var scriptGroup = new LocalScriptGroup();

            Assert.IsNotNull(scriptGroup);
        }