public void TestCase_MakeParameters_strings () { // Init settings for this testcase. NameValueCollection settings = newSettingsWithBasePath (getProjectDirectoryPath ()); Assert.Throws<ArgumentException> (() => { new ChangeEol().MakeParameters(new string[0], settings); }, "Number of argument must be 4."); Assert.Throws<ArgumentException> (() => { new ChangeEol().MakeParameters(new string[1], settings); }, "Number of argument must be 4."); Assert.Throws<ArgumentException> (() => { new ChangeEol().MakeParameters(new string[2], settings); }, "Number of argument must be 4."); Assert.Throws<ArgumentException> (() => { new ChangeEol().MakeParameters(new string[3], settings); }, "Number of argument must be 4."); Assert.Throws<ArgumentException> (() => { new ChangeEol().MakeParameters(new string[4], settings); }, "Number of argument must be 5."); Assert.Throws<NullReferenceException> (() => { new ChangeEol().MakeParameters(new string[5], settings); }, "All of arguments must be not null."); Assert.Throws<ArgumentException> (() => { new ChangeEol().MakeParameters(new string[]{"jid", "pid", "Shift_JIS_LF.txt", "Shift_JIS_LF.txt", "LF"}, settings); }, "Target file(s) must exist."); Assert.Throws<ArgumentException> (() => { new ChangeEol().MakeParameters(new string[]{"jid", "pid", "Shift_JIS_CRLF.txt", "Shift_JIS_CRLF.txt", "LF"}, settings); }, "Zip file must not exist."); string[] args = { "jid", "pid", "Shift_JIS_CRLF.txt", "Shift_JIS_LF.txt", "LF" }; Parameters p = new ChangeEol().MakeParameters(args, settings); Assert.AreEqual (p.JobId, "jid", "1st argument must became JobId."); Assert.AreEqual (p.ProgramId, "pid", "2nd argument must became ProgramId."); Assert.AreEqual (p.SourceFilePath, joinPathSegments(getProjectDirectoryPath(), "Shift_JIS_CRLF.txt"), "3rd argument must became target file path."); Assert.AreEqual (p.DestinationFilePath, joinPathSegments(getProjectDirectoryPath(), "Shift_JIS_LF.txt"), "4th argument must became zip file path."); Assert.AreEqual (p.Eol, "\n"); Assert.AreEqual (p.Charset, Encoding.Default); string[] args2 = { "jid", "pid", "Shift_JIS_CRLF.txt", "Shift_JIS_LF.txt", "CR", "Shift_JIS" }; Parameters p2 = new ChangeEol().MakeParameters(args2, settings); Assert.AreEqual (p2.JobId, "jid", "1st argument must became JobId."); Assert.AreEqual (p2.ProgramId, "pid", "2nd argument must became ProgramId."); Assert.AreEqual (p2.SourceFilePath, joinPathSegments(getProjectDirectoryPath(), "Shift_JIS_CRLF.txt"), "3rd argument must became target file path."); Assert.AreEqual (p2.DestinationFilePath, joinPathSegments(getProjectDirectoryPath(), "Shift_JIS_LF.txt"), "4th argument must became zip file path."); Assert.AreEqual (p2.Eol, "\r"); Assert.AreEqual (p2.Charset, Encoding.GetEncoding ("Shift_JIS")); }
public void TestCase_ChangeEolString_Parameters () { string[] args = { "jid", "pid", "Shift_JIS_CRLF.txt", "Shift_JIS_LF.txt", "LF", "Shift_JIS" }; NameValueCollection settings = newSettingsWithBasePath (getProjectDirectoryPath ()); ChangeEol ce = new ChangeEol (); Parameters p = ce.MakeParameters(args, settings); ce.ChangeEolString (p); string lfFile = joinPathSegments (getProjectDirectoryPath (), "Shift_JIS_LF.txt"); Assert.True(File.Exists(lfFile)); Assert.AreEqual("Shift_JIS CRLF\nしふとじす しーあるえるえふ\nShift_JIS CRLF\nしふとじす しーあるえるえふ\n", File.ReadAllText(lfFile, Encoding.GetEncoding("Shift_JIS"))); }
public void TestCase_EmbedDateTime_string () { ChangeEol ce = new ChangeEol (); string yyyyMMdd = DateTime.Now.ToString ("yyyyMMdd"); Assert.AreEqual ("foo_yyyyMMdd.txt", ce.EmbedDateTime ("foo_yyyyMMdd.txt")); Assert.AreEqual ("foo_" + yyyyMMdd + ".txt", ce.EmbedDateTime ("foo_{yyyyMMdd}.txt")); }