Пример #1
0
        public void TestNUglifyCombinedFail()
        {
            // create the task
            var task = new NUglify();

            // common settings
            task.JsKnownGlobalNames = "jQuery,$";
            task.JsEvalTreatment    = "MakeImmediateSafe";
            task.Switches           = "-rename:none -reorder:N";

            // set up the JS files
            task.JsSourceFiles = new[] {
                new TaskItem()
                {
                    ItemSpec = @"Dll\Input\NUglifyTask\file1.js"
                },
                new TaskItem()
                {
                    ItemSpec = @"Dll\Input\NUglifyTask\fail.js"
                },
            };

            // set up the CSS files
            task.CssSourceFiles = new[] {
                new TaskItem()
                {
                    ItemSpec = @"Dll\Input\NUglifyTask\test1.css"
                },
                new TaskItem()
                {
                    ItemSpec = @"Dll\Input\NUglifyTask\fail.css"
                },
            };

            // our mockup build engine
            task.BuildEngine = new TestBuildEngine()
            {
                MockProjectPath = Path.Combine(testContextInstance.DeploymentDirectory, "mock.csproj")
            };

            // set up the combined file outputs
            task.JsCombinedFileName  = @"Dll\Output\NUglifyTask\CombinedFail.min.js";
            task.CssCombinedFileName = @"Dll\Output\NUglifyTask\CombinedFail.min.css";

            var success = ExecuteAndReport(task);

            // check overall success
            Assert.IsFalse(success, "expected the task to fail");

            // make sure all the files we expect were created
            Assert.IsFalse(File.Exists(Path.Combine(s_outputFolder, "CombinedFail.min.js")), "CombinedFail.min.js should not exist");
            Assert.IsFalse(File.Exists(Path.Combine(s_outputFolder, "CombinedFail.min.css")), "CombinedFail.min.css should not exist");
        }
Пример #2
0
        static void Main(string[] args)
        {
            var @function = args[0];

            switch (function)
            {
            case "coverage":
                CoverageToXml.Convert(args);
                break;

            case "nuglify":
                NUglify.Minify(args);
                break;
            }
        }
Пример #3
0
        private bool ExecuteAndReport(NUglify task)
        {
            var success = task.Execute();

            Trace.Write("TASK RESULT: ");
            Trace.WriteLine(success);

            Trace.WriteLine(string.Empty);
            Trace.WriteLine("BUILD MESSAGES:");
            foreach (var logMessage in ((TestBuildEngine)task.BuildEngine).LogMessages)
            {
                Trace.WriteLine(logMessage);
            }

            return(success);
        }
Пример #4
0
        private NUglify CreateTaskWithInputs()
        {
            // create the task, set it up, and execute it
            var task = new NUglify();

            // common settings
            task.JsKnownGlobalNames = "jQuery,$";
            task.JsEvalTreatment    = "MakeImmediateSafe";
            task.Switches           = "-rename:none -reorder:N";

            // set up the JS files
            task.JsSourceFiles = new[] {
                new TaskItem()
                {
                    ItemSpec = @"Dll\Input\NUglifyTask\file1.js"
                },
                new TaskItem()
                {
                    ItemSpec = @"Dll\Input\NUglifyTask\file2.js"
                },
            };

            // set up the CSS files
            task.CssSourceFiles = new[] {
                new TaskItem()
                {
                    ItemSpec = @"Dll\Input\NUglifyTask\test1.css"
                },
                new TaskItem()
                {
                    ItemSpec = @"Dll\Input\NUglifyTask\test2.css"
                },
            };

            // our mockup build engine
            task.BuildEngine = new TestBuildEngine()
            {
                MockProjectPath = Path.Combine(testContextInstance.DeploymentDirectory, "mock.csproj")
            };

            return(task);
        }