public void serverCode_defaultValues_and_EmptyRequest() { var scriptCombiner = new ScriptCombiner(); scriptCombiner.ProcessRequest(null); Assert.AreEqual (scriptCombiner.apiScriptCombiner.setName,string.Empty , "[empty request] setName"); Assert.AreEqual (scriptCombiner.apiScriptCombiner.version,string.Empty , "[empty request] version"); Assert.IsNotNull(scriptCombiner.apiScriptCombiner.MappingsLocation , "[empty request] mappingsLocation"); var responseHtml = context.response_Read_All(); Assert.AreEqual(EMPTY_RESPONSE,responseHtml, "[empty request] responseHtml should be empty"); request.QueryString["s"] = "setName"; request.QueryString["v"] = "version"; scriptCombiner.ProcessRequest(null); Assert.AreEqual(scriptCombiner.apiScriptCombiner.setName,"setName", "setName value"); Assert.AreEqual(scriptCombiner.apiScriptCombiner.version,"version", "setName value"); responseHtml = context.response_Read_All(); Assert.AreEqual(responseHtml, "othing to do"); //test test handshake request.QueryString["Hello"] = "TM"; scriptCombiner.ProcessRequest(null); responseHtml = context.response_Read_All(); Assert.AreEqual(responseHtml, "othing to doGood Morning", "handshake"); }
public void serverCode_makeRequestFor_one_JavascriptFile() { var scriptCombiner = new ScriptCombiner(); scriptCombiner.apiScriptCombiner.ignoreCache= true; scriptCombiner.apiScriptCombiner.MappingsLocation = "{0}.txt"; var fileContents = "var a=1; // a test js file"; var expectedResult = "\nvar a=1;"; var file1 = "a.js"; var mappingName = "testMapping"; var mappingFile = file1.saveAs(BaseDir.pathCombine(mappingName + ".txt")); var jsFile = fileContents.saveAs(BaseDir.pathCombine("a.js")); Assert.That(mappingFile.fileExists() && mappingFile.fileContents() == file1, "mappingFile not OK"); Assert.That(jsFile.fileExists() && jsFile.fileContents() == fileContents, "mappingFile not OK"); request.QueryString["s"] = mappingName; scriptCombiner.ProcessRequest(null); var responseText = context.response_Read_All(); Assert.AreEqual(expectedResult , responseText , "responseText != expectedResult"); Assert.AreEqual(scriptCombiner.apiScriptCombiner.filesProcessed[0], file1 , "scriptCombiner.filesProcessed[0]"); // these two fails due to weird encoding bug (the text is the same (in ascii)) //Assert.AreEqual(scriptCombiner.minifiedCode , expectedResult, "minifiedCode"); //Assert.AreEqual(scriptCombiner.allScripts.str() , fileContents , "allScripts"); }
public void serverCode_makeRequestFor_two_JavascriptFile() { var scriptCombiner = new ScriptCombiner(); scriptCombiner.apiScriptCombiner.ignoreCache = true; scriptCombiner.apiScriptCombiner.MappingsLocation = "{0}.txt"; var fileContents1 = "var a=1; // a test js file"; var fileContents2 = "var b=1; // a test js file"; var expectedResult = "\nvar a=1;var b=1;"; var file1 = "a.js"; var file2 = "b.js"; var mappingName = "testMapping"; var mappingContents = file1.line() + file2.line(); mappingContents.saveAs(this.BaseDir.pathCombine(mappingName + ".txt")); fileContents1.saveAs(this.BaseDir.pathCombine(file1)); fileContents2.saveAs(this.BaseDir.pathCombine(file2)); request.QueryString["s"] = mappingName; scriptCombiner.ProcessRequest(null); var responseText = context.response_Read_All(); Assert.AreEqual(expectedResult,responseText, "responseText != expectedResult"); }
public void serverCode_minifyCodeSetting() { var scriptCombiner = new ScriptCombiner(); scriptCombiner.ProcessRequest(null); Assert.IsTrue(scriptCombiner.apiScriptCombiner.minifyCode, "minifyCode should be true"); request.QueryString["s"] = "someValue"; request.QueryString["dontMinify"] = "true"; scriptCombiner.ProcessRequest(null); Assert.IsFalse(scriptCombiner.apiScriptCombiner.minifyCode, "minifyCode should be false"); }