예제 #1
0
		public void TestCase_MakeParameters_strings ()
		{
			// Init settings for this testcase.
			NameValueCollection settings = newSettingsWithBasePath (getProjectDirectoryPath ());

			Assert.Throws<ArgumentException> (() => {
				new WaitFile().MakeParameters(new string[0], settings);
			});
			Assert.Throws<ArgumentException> (() => {
				new WaitFile().MakeParameters(new string[1], settings);
			});
			Assert.Throws<ArgumentException> (() => {
				new WaitFile().MakeParameters(new string[2], settings);
			});
			Assert.Throws<ArgumentException> (() => {
				new WaitFile().MakeParameters(new string[3], settings);
			});
			Assert.Throws<ArgumentException> (() => {
				new WaitFile().MakeParameters(new string[4], settings);
			});
			Assert.Throws<ArgumentNullException> (() => {
				new WaitFile().MakeParameters(new string[5], settings);
			});
			Assert.Throws<ArgumentException> (() => {
				new WaitFile().MakeParameters(new string[]{"jid", "pid", "app.config", "0", "3"}, settings);
			}, "Interval seconds must be greater than 0.");
			Assert.Throws<ArgumentException> (() => {
				new WaitFile().MakeParameters(new string[]{"jid", "pid", "app.config", "1", "0"}, settings);
			}, "Times must be greater than 0.");

			string[] args = { "jid", "pid", "app.config", "1", "3" };
			Parameters p = new WaitFile().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.TargetFilePath, 
				joinPathSegments(getProjectDirectoryPath(), "app.config"),
				"3rd argument must became target file path.");
			Assert.AreEqual (p.IntervalSeconds, 1,
				"4th argument must became interval seconds.");
			Assert.AreEqual (p.Times, 3,
				"5th argument must became times.");
		}
예제 #2
0
		public void TestCase_Execute_strings ()
		{
			NameValueCollection settings = newSettingsWithBasePath (getProjectDirectoryPath ());
			string[] args = { "jid", "pid", "packages.config", "1", "3" };
			WaitFile wf = new WaitFile ();
			Assert.AreEqual (WaitFile.ExitCodeNormal, wf.Execute (args, settings));

			string[] args2 = { "jid", "pid", "finish.txt", "1", "3" };
			WaitFile wf2 = new WaitFile ();
			Assert.AreEqual (WaitFile.ExitCodeError, wf2.Execute (args2, settings));

			string[] args3 = { "jid", "pid", "finish.txt", "1", "3" };
			WaitFile wf3 = new WaitFile ();

			Task.Run(() => {
				Thread.Sleep(1000);
				File.Copy(joinPathSegments(getProjectDirectoryPath(), "packages.config"),
					joinPathSegments(getProjectDirectoryPath(), "finish.txt"));
			});

			Assert.AreEqual (WaitFile.ExitCodeNormal, wf3.Execute (args3, settings));

		}
예제 #3
0
		public void TestCase_EmbedDateTime_string ()
		{
			WaitFile mz = new WaitFile ();
			string yyyyMMdd = DateTime.Now.ToString ("yyyyMMdd");

			Assert.AreEqual ("foo_yyyyMMdd.txt", mz.EmbedDateTime ("foo_yyyyMMdd.txt"));
			Assert.AreEqual ("foo_" + yyyyMMdd + ".txt", mz.EmbedDateTime ("foo_{yyyyMMdd}.txt"));
		}
예제 #4
0
		public void TestCase_CheckIfFileExists_Parameters ()
		{
			WaitFile wf = new WaitFile ();

			NameValueCollection settings = newSettingsWithBasePath (getProjectDirectoryPath ());
			string[] args = { "jid", "pid", "packages.config", "1", "3" };
			Parameters p = wf.MakeParameters(args, settings);
			Assert.True (wf.CheckIfFileExists (p));

			string[] args2 = { "jid", "pid", "packages.foo", "1", "3" };
			Parameters p2 = wf.MakeParameters(args2, settings);
			Assert.False (wf.CheckIfFileExists (p2));
		}