public void AddTest_3()
 {
     string temp;
     ScriptManager sm = new ScriptManager();
     bool result = sm.Add(_incorrectCode, true, out temp);
     Assert.AreNotEqual(temp, "");
     Assert.IsFalse(result);
 }
 public void AddTest_1()
 {
     string temp;
     ScriptManager sm = new ScriptManager();
     bool result = sm.Add("text", true, out temp);
     Assert.IsNotNull(temp);
     Assert.IsFalse(result);
 }
        public void ScriptManager_Add_Null_Throws_Exception_Test()
        {
            var cacheManager = new Mock<ICacheManager>();
            var contextAccessor = new Mock<IHttpContextAccessor>();
            var target = new ScriptManager(cacheManager.Object, contextAccessor.Object);

            ScriptInfo info = null;
            target.Add(info);
        }
        public void AddTest_3()
        {
            string        temp;
            ScriptManager sm     = new ScriptManager();
            bool          result = sm.Add(_incorrectCode, true, out temp);

            Assert.AreNotEqual(temp, "");
            Assert.IsFalse(result);
        }
        public void AddTest_1()
        {
            string        temp;
            ScriptManager sm     = new ScriptManager();
            bool          result = sm.Add("text", true, out temp);

            Assert.IsNotNull(temp);
            Assert.IsFalse(result);
        }
 public void AddTest_4()
 {
     string temp;
     ScriptManager sm = new ScriptManager();
     File.WriteAllText("AddTest_4.cs", _correctCode);
     bool result = sm.Add("AddTest_4.cs", true, out temp);
     File.Delete("AddTest_4.cs");
     Assert.AreEqual(temp, "");
     Assert.IsTrue(result);
 }
        public static MvcHtmlString AddScriptSource(this HtmlHelper helper, Func<dynamic, HelperResult> source, string key, string area = null)
        {
            var scriptType = ScriptType.JavaScript;

            var info = new ScriptInfo(source(null).ToHtmlString(), scriptType, key, area);

            var manager = new ScriptManager();

            manager.Add(info);

            return MvcHtmlString.Empty;
        }
        public static MvcHtmlString AddJavaScript(this HtmlHelper helper, string localPath, string area = null)
        {
            var scriptType = ScriptType.JavaScript;

            var info = new ScriptInfo(localPath, helper.ViewContext.HttpContext.Server.MapPath(localPath).Replace(@"/", @"\"), scriptType,  area);

            var manager = new ScriptManager();

            manager.Add(info);

            return MvcHtmlString.Empty;
        }
        public void AddTest_4()
        {
            string        temp;
            ScriptManager sm = new ScriptManager();

            File.WriteAllText("AddTest_4.cs", _correctCode);
            bool result = sm.Add("AddTest_4.cs", true, out temp);

            File.Delete("AddTest_4.cs");
            Assert.AreEqual(temp, "");
            Assert.IsTrue(result);
        }
        public void RemoveTest_2()
        {
            string        temp;
            ScriptManager sm = new ScriptManager();

            File.WriteAllText("RemoveTest_2.cs", _correctCode);
            bool result = sm.Add("RemoveTest_2.cs", true, out temp);

            result = sm.Remove("RemoveTest_2.cs");
            Assert.IsTrue(result);
            File.Delete("RemoveTest_2.cs");
        }
        public void ExecuteTest()
        {
            string        temp;
            ScriptManager sm = new ScriptManager();

            File.WriteAllText("RemoveTest_2.cs", _correctCode);
            bool result = sm.Add("RemoveTest_2.cs", true, out temp);

            File.Delete("RemoveTest_2.cs");
            try
            {
                sm.Execute();
            }
            catch (Exception ex)
            {
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }
        }
        public void ScriptManager_Add_External_StyleSheet_ScriptInfo_Test()
        {
            var cacheManager = new Mock<ICacheManager>();
            var contextAccessor = new Mock<IHttpContextAccessor>();
            var list = new Mock<IScriptFileList>();

            var context = new Mock<HttpContextBase>
            {
                DefaultValue = DefaultValue.Mock
            };

            contextAccessor.Setup(c => c.Current()).Returns(context.Object);
            context.SetupGet(c => c.Application["__sm__Stylesheet"]).Returns(() => list.Object);

            var target = new ScriptManager(cacheManager.Object, contextAccessor.Object);

            IScriptInfo info = new ScriptInfo(null, "SomeLocalPath", ScriptType.Stylesheet);

            target.Add(info);

            list.Verify(l => l.Add(info), Times.Once());
        }
 public void ExecuteTest()
 {
     string temp;
     ScriptManager sm = new ScriptManager();
     File.WriteAllText("RemoveTest_2.cs", _correctCode);
     bool result = sm.Add("RemoveTest_2.cs", true, out temp);
     File.Delete("RemoveTest_2.cs");
     try
     {
         sm.Execute();
     }
     catch (Exception ex)
     {
         Assert.Fail("Expected no exception, but got: " + ex.Message);
     }
 }
 public void RemoveTest_2()
 {
     string temp;
     ScriptManager sm = new ScriptManager();
     File.WriteAllText("RemoveTest_2.cs", _correctCode);
     bool result = sm.Add("RemoveTest_2.cs", true, out temp);
     result = sm.Remove("RemoveTest_2.cs");
     Assert.IsTrue(result);
     File.Delete("RemoveTest_2.cs");
 }