public void GetArgumentsForFileMode( string targetFolder, string targetFile1, string targetFile2, string format) { int ExpectedWriteLineCallCount = 0; List<string> ExpectedWriteLineCallValues = new List<string>(); if (targetFolder != null) { ++ExpectedWriteLineCallCount; ExpectedWriteLineCallValues.Add(targetFolder); } string[] targetFiles = null; if (targetFile2 != null) { targetFiles = new string[] { targetFile1, targetFile2 }; ExpectedWriteLineCallCount += 2; } else if (targetFile1 != null) { targetFiles = new string[] { targetFile1, }; ++ExpectedWriteLineCallCount; } ExpectedWriteLineCallValues.AddRange(targetFiles); ActionItem TestSubject = new ActionItem(); TestSubject.TargetListMode = TargetMode.File; TestSubject.ArgumentsFormat = format; RecorderWriterBase WriterRecorder = new RecorderWriterBase("bogas $%@#!"); TestSubject.Writer = WriterRecorder; string ActualArguments = TestSubject.GetArguments(targetFolder, targetFiles); Assert.AreEqual(ExpectedWriteLineCallCount, WriterRecorder.Recordings.WriteLineStringRecording.CallCount, "Writeline was not called the correct number of times."); for (int i = 0; i < ExpectedWriteLineCallCount; i++) { Assert.In(ExpectedWriteLineCallValues[i], WriterRecorder.Recordings.WriteLineStringRecording.AllPassedStringline, string.Format("This value was not written: {0}", ExpectedWriteLineCallValues[i])); } string ExpectedArguements; if (format != null) { format = format.Replace("{0}", @"""{0}"" "); ExpectedArguements = string.Format(format, TestSubject.TempFilePath); } else ExpectedArguements = string.Format(@"""{0}"" ", TestSubject.TempFilePath); Assert.AreEqual(ExpectedArguements, ActualArguments); Assert.IsTrue(WriterRecorder.Recordings.DisposeRecording.Called, "The writer was not disposed!"); }
public void GetArgumentsForCommandLineMode( string targetFolder, string targetFile1, string targetFile2, string format, string expectedArguements) { string[] targetFiles = null; if (targetFile2 != null) targetFiles = new string[] { targetFile1, targetFile2 }; else if (targetFile1 != null) targetFiles = new string[] { targetFile1, }; ActionItem TestSubject = new ActionItem(); TestSubject.TargetListMode = TargetMode.CommandLine; TestSubject.ArgumentsFormat = format; string ActualArguments = TestSubject.GetArguments(targetFolder, targetFiles); Assert.AreEqual(expectedArguements, ActualArguments); }