Exemple #1
0
        public void ExecuteWithProjectItemGeneratesTheRightArguments()
        {
            var info = new ProcessInfo("Test");
            var item = new Comment
            {
                Project = new Project("Test")
            };
            var context = new TaskExecutionContext(
                new TaskExecutionParameters
            {
                Project = item.Project
            });
            var logFile  = context.GeneratePathInWorkingDirectory("Comment.log");
            var executor = new ProcessExecutorOverride
            {
                OnExecute = (pi, p, i, o) =>
                {
                    Assert.AreSame(info, pi);
                    Assert.AreEqual("Test", p);
                    Assert.AreEqual("Comment", i);
                    Assert.AreEqual(logFile, o);
                    return(null);
                }
            };

            executor.Execute(info, item, context);
        }
Exemple #2
0
        public ProcessResult Execute(ProcessInfo processInfo, ProjectItem item, TaskExecutionContext context)
        {
            var outputFile = context.GeneratePathInWorkingDirectory(item.NameOrType + ".log");

            if ((this.Item == null) || (this.Context == null))
            {
                return(this.Execute(processInfo,
                                    item.Project.Name,
                                    item.NameOrType,
                                    outputFile));
            }

            Assert.AreEqual(this.FileName, processInfo.FileName);
            var actual = processInfo.Arguments == null ? null : processInfo.Arguments.ToString();

            Assert.AreEqual(this.Arguments, actual);
            Assert.AreEqual(this.WorkingDirectory, processInfo.WorkingDirectory);
            Assert.AreSame(this.Item, item);
            Assert.AreEqual(this.Context, context);

            var fileSystemMock = new Mock <IFileSystem>();

            fileSystemMock.Setup(fs => fs.OpenFileForRead(outputFile)).Returns(new MemoryStream());
            var result = new ProcessResult(
                fileSystemMock.Object,
                outputFile,
                this.ExitCode,
                this.TimedOut,
                this.Failed);

            return(result);
        }
        public ProcessResult Execute(ProcessInfo processInfo, ProjectItem item, TaskExecutionContext context)
        {
            var outputFile = context.GeneratePathInWorkingDirectory(item.NameOrType + ".log");
            if ((this.Item == null) || (this.Context == null))
            {
                return this.Execute(processInfo,
                                    item.Project.Name,
                                    item.NameOrType,
                                    outputFile);
            }

            Assert.AreEqual(this.FileName, processInfo.FileName);
            var actual = processInfo.Arguments == null ? null : processInfo.Arguments.ToString();
            Assert.AreEqual(this.Arguments, actual);
            Assert.AreEqual(this.WorkingDirectory, processInfo.WorkingDirectory);
            Assert.AreSame(this.Item, item);
            Assert.AreEqual(this.Context, context);

            var fileSystemMock = new Mock<IFileSystem>();
            fileSystemMock.Setup(fs => fs.OpenFileForRead(outputFile)).Returns(new MemoryStream());
            var result = new ProcessResult(
                fileSystemMock.Object,
                outputFile,
                this.ExitCode,
                this.TimedOut,
                this.Failed);
            return result;
        }
        public void GeneratePathInWorkingDirectoryGeneratesDefaultPath()
        {
            var projectName = "Test";
            var filename    = "aTestFile.txt";
            var expected    = Path.Combine(
                Environment.CurrentDirectory,
                projectName,
                "working",
                filename);
            var context = new TaskExecutionContext(
                new TaskExecutionParameters
            {
                Project = new Project(projectName)
            });
            var actual = context.GeneratePathInWorkingDirectory(filename);

            Assert.AreEqual(expected, actual);
        }
 public void ExecuteWithProjectItemGeneratesTheRightArguments()
 {
     var info = new ProcessInfo("Test");
     var item = new Comment
                    {
                        Project = new Project("Test")
                    };
     var context = new TaskExecutionContext(
         new TaskExecutionParameters
             {
                 Project = item.Project
             });
     var logFile = context.GeneratePathInWorkingDirectory("Comment.log");
     var executor = new ProcessExecutorOverride
                        {
                            OnExecute = (pi, p, i, o) =>
                                            {
                                                Assert.AreSame(info, pi);
                                                Assert.AreEqual("Test", p);
                                                Assert.AreEqual("Comment", i);
                                                Assert.AreEqual(logFile, o);
                                                return null;
                                            }
                        };
     executor.Execute(info, item, context);
 }
 /// <summary>
 /// Executes the specified process for a project item.
 /// </summary>
 /// <param name="processInfo">The process info.</param>
 /// <param name="item">The item.</param>
 /// <returns>
 /// The result of the execution.
 /// </returns>
 public ProcessResult Execute(ProcessInfo processInfo, ProjectItem item, TaskExecutionContext context)
 {
     var logFile = context.GeneratePathInWorkingDirectory(item.NameOrType + ".log");
     return this.Execute(processInfo, item.Project.Name, item.NameOrType, logFile);
 }
        /// <summary>
        /// Executes the specified process for a project item.
        /// </summary>
        /// <param name="processInfo">The process info.</param>
        /// <param name="item">The item.</param>
        /// <returns>
        /// The result of the execution.
        /// </returns>
        public ProcessResult Execute(ProcessInfo processInfo, ProjectItem item, TaskExecutionContext context)
        {
            var logFile = context.GeneratePathInWorkingDirectory(item.NameOrType + ".log");

            return(this.Execute(processInfo, item.Project.Name, item.NameOrType, logFile));
        }
 public void GeneratePathInWorkingDirectoryGeneratesDefaultPath()
 {
     var projectName = "Test";
     var filename = "aTestFile.txt";
     var expected = Path.Combine(
         Environment.CurrentDirectory,
         projectName,
         "working",
         filename);
     var context = new TaskExecutionContext(
         new TaskExecutionParameters
             {
                 Project = new Project(projectName)
             });
     var actual = context.GeneratePathInWorkingDirectory(filename);
     Assert.AreEqual(expected, actual);
 }