public void ImportFileMovesFile()
        {
            var source      = "C:\\data.tst";
            var destination = Path.Combine(
                Environment.CurrentDirectory,
                "Test",
                "20100101120101",
                Path.GetFileName(source));
            var writerMock = new Mock <XmlWriter>(MockBehavior.Strict);

            writerMock.Setup(w => w.WriteStartElement(null, "file", null)).Verifiable();
            writerMock.MockWriteAttributeString("time", "2010-01-01T12:01:01");
            writerMock.Setup(w => w.WriteString(Path.GetFileName(destination))).Verifiable();
            writerMock.Setup(w => w.WriteEndElement()).Verifiable();
            var fileSystemMock = new Mock <IFileSystem>(MockBehavior.Strict);

            fileSystemMock.Setup(fs => fs.MoveFile(source, destination)).Verifiable();
            var clockMock = new Mock <IClock>(MockBehavior.Strict);

            clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1));
            var context = new TaskExecutionContext(
                new TaskExecutionParameters
            {
                XmlWriter  = writerMock.Object,
                FileSystem = fileSystemMock.Object,
                Clock      = clockMock.Object,
                Project    = new Project("Test"),
                BuildName  = "20100101120101"
            });

            context.ImportFile(source, true);
            writerMock.Verify();
            fileSystemMock.Verify();
        }
        /// <summary>
        /// Executes this task.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        /// The child tasks to execute.
        /// </returns>
        protected override IEnumerable<Task> OnRun(TaskExecutionContext context)
        {
            foreach (var file in this.Files)
            {
                logger.Info("Merging file '{0}'", file.File);
                context.ImportFile(file.File, file.Delete);
            }

            return null;
        }
        /// <summary>
        /// Executes this task.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        /// The child tasks to execute.
        /// </returns>
        protected override IEnumerable <Task> OnRun(TaskExecutionContext context)
        {
            foreach (var file in this.Files)
            {
                logger.Info("Merging file '{0}'", file.File);
                context.ImportFile(file.File, file.Delete);
            }

            return(null);
        }
 public void ImportFileMovesFile()
 {
     var source = "C:\\data.tst";
     var destination = Path.Combine(
         Environment.CurrentDirectory,
         "Test",
         "20100101120101",
         Path.GetFileName(source));
     var writerMock = new Mock<XmlWriter>(MockBehavior.Strict);
     writerMock.Setup(w => w.WriteStartElement(null, "file", null)).Verifiable();
     writerMock.MockWriteAttributeString("time", "2010-01-01T12:01:01");
     writerMock.Setup(w => w.WriteString(Path.GetFileName(destination))).Verifiable();
     writerMock.Setup(w => w.WriteEndElement()).Verifiable();
     var fileSystemMock = new Mock<IFileSystem>(MockBehavior.Strict);
     fileSystemMock.Setup(fs => fs.MoveFile(source, destination)).Verifiable();
     var clockMock = new Mock<IClock>(MockBehavior.Strict);
     clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1));
     var context = new TaskExecutionContext(
         new TaskExecutionParameters
             {
                 XmlWriter = writerMock.Object,
                 FileSystem = fileSystemMock.Object,
                 Clock = clockMock.Object,
                 Project = new Project("Test"),
                 BuildName = "20100101120101"
             });
     context.ImportFile(source, true);
     writerMock.Verify();
     fileSystemMock.Verify();
 }