Esempio n. 1
0
        public void CreatesFile()
        {
            CreateOrUpdateFileProcessor processor = new CreateOrUpdateFileProcessor();

            processor.SetParameter("FileName", GetCurrentTestResultsFilePath("out.txt"));
            processor.SetParameter("UpdateModificationDateIfExists", false);
            processor.Init(RunInfo);
            // File is irrelevant
            FileInfo         file   = GetTestFile("BasicTextFile.txt");
            ProcessingResult result = processor.Process(file, MatchResultType.Yes,
                                                        new string[0], new FileInfo[0], ProcessInput.OriginalFile, CancellationToken.None);

            processor.Cleanup();
            Assert.AreEqual(ProcessingResultType.Success, result.Type);
            Assert.AreEqual(1, result.OutputFiles.Length);
        }
Esempio n. 2
0
        public void DoesNotUpdateDate()
        {
            CreateOrUpdateFileProcessor processor = new CreateOrUpdateFileProcessor();
            string outputPath = GetCurrentTestResultsFilePath("out.txt");

            File.WriteAllText(outputPath, "This file will not have its date updated.");
            File.SetLastWriteTime(outputPath, DateTime.Now.AddYears(-2));
            processor.SetParameter("FileName", outputPath);
            processor.SetParameter("UpdateModificationDateIfExists", false);
            processor.Init(RunInfo);
            // File is irrelevant
            FileInfo         file   = GetTestFile("BasicTextFile.txt");
            ProcessingResult result = processor.Process(file, MatchResultType.Yes,
                                                        new string[0], new FileInfo[0], ProcessInput.OriginalFile, CancellationToken.None);

            processor.Cleanup();
            Assert.AreEqual(ProcessingResultType.Success, result.Type);
            Assert.AreEqual(0, result.OutputFiles.Length);
            Assert.AreNotEqual(DateTime.Now.Year, File.GetLastWriteTime(outputPath).Year);
        }