public void Check_GetOutputFilePath() { string targetfile_Name = "lib"; string expected_OutputPath = Path.Combine(OutputPath, BaseName) + targetfile_Name; //arrange var targetfile = new TargetFile(targetfile_Name); //act var targetfilewriter = new TargetFileWriter(OutputPath, BaseName); var actual = targetfilewriter.GetOutputFilePath(targetfile); actual.Should().Be(expected_OutputPath); }
public void Check_Write_TextWriter() { string targetfile_Name = "lib"; string expected_OutputPath = Path.Combine(OutputPath, BaseName) + targetfile_Name; //arrange var targetfile = new TargetFile(targetfile_Name); var sw = new StringWriter(); //act var targetfilewriter = new TargetFileWriter(OutputPath, BaseName); targetfilewriter.Write(targetfile, sw); sw.ToString().Should().NotBeNullOrEmpty(); }
static ExitCode processFiles(List <string> files, string resultFile, List <Replacement> toReplace, out string errorMsg, int utfOption) { ExitCode rc = ExitCode.Success; errorMsg = Errors.EM_SUCCESS; // Create temporary file string tempfile = Path.GetTempFileName(); if (File.Exists(tempfile)) { File.Delete(tempfile); } TargetFileWriter writer = new TargetFileWriter(tempfile, FileMode.CreateNew); // Open each input file in read mode, and copy its content to the destination file bool isFirst = true; foreach (string file in files) { if (isFirst) { writer.Append(file); } else { writer.AppendWithoutBom(file, utfOption); } isFirst = false; } writer.Close(); // Replace all placeholders ReplaceTextOrDeleteLine(tempfile, resultFile, toReplace); if (File.Exists(tempfile)) { File.Delete(tempfile); } return(rc); }