public void FailsFileInUse() { string outputFilename = GetCurrentTestResultsFilePath("out.txt"); FilterLinesProcessor processor = new FilterLinesProcessor(); processor.SetParameter("OverwriteExistingFile", true); processor.SetParameter("FileName", outputFilename); processor.SetParameter("TextToMatch", "foo"); using (FileStream fs = File.OpenWrite(outputFilename)) { FileInfo file = GetTestFile("Lipsum.txt"); processor.Init(RunInfo); ProcessingResult result = processor.Process(file, MatchResultType.Yes, new string[0], new FileInfo[0], ProcessInput.OriginalFile, CancellationToken.None); processor.Cleanup(); Assert.AreEqual(ProcessingResultType.Failure, result.Type); Assert.AreEqual(0, result.OutputFiles.Length); } }
public void SuccessNoTrailingNewline() { FilterLinesProcessor processor = new FilterLinesProcessor(); processor.SetParameter("FilterType", LineFilterType.KeepMatchingLines); processor.SetParameter("TextToMatch", "il"); processor.SetParameter("UseRegex", false); processor.SetParameter("CaseSensitive", false); processor.SetParameter("LineEndings", LineEndings.MatchInput); processor.SetParameter("OutputEncoding", OutputEncodingType.MatchInput); processor.SetParameter("FileName", GetCurrentTestResultsFilePath("out.txt")); processor.SetParameter("OverwriteExistingFile", true); processor.SetParameter("MoveOriginalToRecycleBin", false); FileInfo file = GetTestFile("TextFileWithNoTrailingNewline.txt"); processor.Init(RunInfo); ProcessingResult result = processor.Process(file, MatchResultType.Yes, new string[0], new FileInfo[0], ProcessInput.OriginalFile, CancellationToken.None); Assert.AreEqual(ProcessingResultType.Success, result.Type); Assert.AreEqual(1, result.OutputFiles.Length); processor.Cleanup(); }