public void RunsWithDefaultParametersForServiceProfile()
        {
            var appName = "WinService";
            var result = GenerateResultMock();
            var executablePath = Path.Combine(defaultWorkingDir, "Profile");
            var executor = GenerateExecutorMock(
                executablePath,
                this.defaultExecutableArgs + " /service:" + appName,
                defaultWorkingDir,
                600000);
            var fileSystemMock = this.InitialiseFileSystemMock(executablePath);
            var logger = mocks.DynamicMock<ILogger>();
            var task = new AntsPerformanceProfilerTask(executor, fileSystemMock, logger) { PublishFiles = false };
            task.Service = appName;

            Expect.Call(result.Status).PropertyBehavior();
            mocks.ReplayAll();
            result.Status = IntegrationStatus.Unknown;
            task.Run(result);
            mocks.VerifyAll();
        }
 public void ValidateDoesNotAllowBothQuietAndVerbose()
 {
     var trace = new ConfigurationTrace(null, null);
     var errorProcesser = this.mocks.StrictMock<IConfigurationErrorProcesser>();
     Expect.Call(() => errorProcesser.ProcessError("Cannot have both verbose and quiet set"));
     var task = new AntsPerformanceProfilerTask();
     task.Quiet = true;
     task.Verbose = true;
     this.mocks.ReplayAll();
     task.Validate(null, trace, errorProcesser);
     this.mocks.VerifyAll();
 }
 public void ValidateDoesNotAllowaNegativeProfilerTimeout()
 {
     var trace = new ConfigurationTrace(null, null);
     var errorProcesser = this.mocks.StrictMock<IConfigurationErrorProcesser>();
     Expect.Call(() => errorProcesser.ProcessError("profilerTimeout cannot be negative"));
     var task = new AntsPerformanceProfilerTask();
     task.ProfilerTimeOut = -1;
     this.mocks.ReplayAll();
     task.Validate(null, trace, errorProcesser);
     this.mocks.VerifyAll();
 }
 public void DefaultConstructorSetsFileSystemAndLogger()
 {
     var task = new AntsPerformanceProfilerTask();
     Assert.IsInstanceOf<SystemIoFileSystem>(task.FileSystem);
     Assert.IsInstanceOf<DefaultLogger>(task.Logger);
 }
        public void XmlArgsFilesExcludesWorkingDirectoryWhenRooted()
        {
            var appName = "testApp.exe";
            var result = GenerateResultMock();
            var executablePath = Path.Combine(defaultWorkingDir, "Profile");
            var executor = GenerateExecutorMock(
                executablePath,
                this.defaultExecutableArgs + " /e:" + Path.Combine(defaultWorkingDir, appName) + " /argfile:c:\\args.xml",
                defaultWorkingDir,
                600000);
            var fileSystemMock = this.InitialiseFileSystemMock(executablePath);
            var logger = mocks.DynamicMock<ILogger>();
            var task = new AntsPerformanceProfilerTask(executor, fileSystemMock, logger) { PublishFiles = false };
            task.Application = appName;
            task.XmlArgsFile = "c:\\args.xml";

            Expect.Call(result.Status).PropertyBehavior();
            mocks.ReplayAll();
            result.Status = IntegrationStatus.Unknown;
            task.Run(result);
            mocks.VerifyAll();
        }
        public void RunsWithOptionalParametersForAppProfile()
        {
            var appName = "testApp.exe";
            var result = GenerateResultMock();
            var executablePath = Path.Combine(defaultWorkingDir, "Profile");
            var executor = GenerateExecutorMock(
                executablePath,
                "/wd:" + defaultWorkingDir +
                    " /out:" + Path.Combine(defaultWorkingDir, "somewhereElse.txt") +
                    " /t:240 /ll /ows /sm /sp /rs /is:off /in:off /comp:off /simp:off /notriv:off /e:" + Path.Combine(defaultWorkingDir, appName) +
                    " /args:args /q /v /argfile:" + Path.Combine(defaultWorkingDir, "args.xml") +
                    " /threshold:10",
                defaultWorkingDir,
                600000);
            var fileSystemMock = this.InitialiseFileSystemMock(executablePath);
            var logger = mocks.DynamicMock<ILogger>();
            var task = new AntsPerformanceProfilerTask(executor, fileSystemMock, logger) { PublishFiles = false };
            task.Application = appName;
            task.Quiet = true;
            task.Verbose = true;
            task.XmlArgsFile = "args.xml";
            task.OutputFile = "somewhereElse.txt";
            task.ApplicationArguments = "args";
            task.ProfilerTimeOut = 240;
            task.TraceLevelValue = AntsPerformanceProfilerTask.TraceLevel.Line;
            task.OnlyWithSource = true;
            task.UseSampling = true;
            task.IncludeSource = false;
            task.AllowInlining = false;
            task.Compensate = false;
            task.SimplifyStackTraces = false;
            task.AvoidTrivial = false;
            task.IncludeSubProcesses = true;
            task.RecordSqlAndIO = true;
            task.ForceOverwrite = false;
            task.Threshold = 10;

            Expect.Call(result.Status).PropertyBehavior();
            mocks.ReplayAll();
            result.Status = IntegrationStatus.Unknown;
            task.Run(result);
            mocks.VerifyAll();
        }
        public void RunsWithBaseDirectoryForAppProfileAndAllFiles()
        {
            var baseDir = "aDirSomewhere";
            var appName = "testApp.exe";
            var result = GenerateResultMock();
            var executablePath = Path.Combine(baseDir, "Profile");
            var executor = GenerateExecutorMock(
                executablePath,
                "/wd:" + baseDir +
                    " /out:" + Path.Combine(baseDir, "AntsPerformanceAnalysis.txt") +
                    " /t:120 /ml /f /is:on /in:on /comp:on /simp:on /notriv:on /e:" + Path.Combine(baseDir, appName) +
                    " /csv:" + Path.Combine(baseDir, "summary.csv") +
                    " /xml:" + Path.Combine(baseDir, "summary.xml") +
                    " /h:" + Path.Combine(baseDir, "summary.html") +
                    " /calltree:" + Path.Combine(baseDir, "calltree.xml") +
                    " /cth:" + Path.Combine(baseDir, "calltree.html") +
                    " /data:" + Path.Combine(baseDir, "data.out"),
                baseDir,
                600000);
            var fileSystemMock = this.InitialiseFileSystemMock(executablePath);
            var logger = mocks.DynamicMock<ILogger>();
            var task = new AntsPerformanceProfilerTask(executor, fileSystemMock, logger) { PublishFiles = false };
            task.Application = appName;
            task.BaseDirectory = baseDir;
            task.SummaryCsvFile = "summary.csv";
            task.SummaryXmlFile = "summary.xml";
            task.SummaryHtmlFile = "summary.html";
            task.CallTreeXmlFile = "calltree.xml";
            task.CallTreeHtmlFile = "calltree.html";
            task.DataFile = "data.out";

            Expect.Call(result.Status).PropertyBehavior();
            mocks.ReplayAll();
            result.Status = IntegrationStatus.Unknown;
            task.Run(result);
            mocks.VerifyAll();
        }
        public void RunsWithDefaultParametersForAppProfilePublishesAllFiles()
        {
            var appName = "testApp.exe";
            var result = GenerateResultMock();
            var executablePath = Path.Combine(defaultWorkingDir, "Profile");
            var executor = GenerateExecutorMock(
                executablePath,
                this.defaultExecutableArgs + " /e:" + Path.Combine(defaultWorkingDir, appName) +
                    " /csv:" + Path.Combine(defaultWorkingDir, "summary.csv") +
                    " /xml:" + Path.Combine(defaultWorkingDir, "summary.xml") +
                    " /h:" + Path.Combine(defaultWorkingDir, "summary.html") +
                    " /calltree:" + Path.Combine(defaultWorkingDir, "calltree.xml") +
                    " /cth:" + Path.Combine(defaultWorkingDir, "calltree.html") +
                    " /data:" + Path.Combine(defaultWorkingDir, "data.out"),
                defaultWorkingDir,
                600000);
            var fileSystemMock = this.InitialiseFileSystemMock(executablePath);

            ExpectFileCheckAndCopy(fileSystemMock, "AntsPerformanceAnalysis.txt");
            ExpectFileCheckAndCopy(fileSystemMock, "summary.csv");
            ExpectFileCheckAndCopy(fileSystemMock, "summary.xml");
            ExpectFileCheckAndCopy(fileSystemMock, "summary.html");
            ExpectFileCheckAndCopy(fileSystemMock, "calltree.xml");
            ExpectFileCheckAndCopy(fileSystemMock, "calltree.html");
            ExpectFileCheckAndCopy(fileSystemMock, "data.out");

            var logger = mocks.DynamicMock<ILogger>();
            var task = new AntsPerformanceProfilerTask(executor, fileSystemMock, logger);
            task.Application = appName;
            task.SummaryCsvFile = "summary.csv";
            task.SummaryXmlFile = "summary.xml";
            task.SummaryHtmlFile = "summary.html";
            task.CallTreeXmlFile = "calltree.xml";
            task.CallTreeHtmlFile = "calltree.html";
            task.DataFile = "data.out";

            Expect.Call(result.Status).PropertyBehavior();
            mocks.ReplayAll();
            result.Status = IntegrationStatus.Unknown;
            task.Run(result);
            mocks.VerifyAll();
        }