예제 #1
0
		public void TestCase_GetFileNames_string ()
		{
			string basePath = getProjectDirectoryPath();
			string[] fileNames = new MakeZip ().GetFileNames(joinPathSegments(basePath, "*.config"));
			Assert.Contains (joinPathSegments(basePath, "app.config"), fileNames);
			Assert.Contains (joinPathSegments(basePath, "packages.config"), fileNames);
		}
예제 #2
0
		public void TestCase_EmbedDateTime_string ()
		{
			MakeZip mz = new MakeZip ();
			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"));
		}
예제 #3
0
		public void TestCase_MakeZipEntryName_Parameters_string ()
		{
			string[] args = { "jid", "pid", "*.config", "hello.zip" };
			string basePath = getProjectDirectoryPath();
			NameValueCollection settings = newSettingsWithBasePath (basePath);
			Parameters p = new MakeZip().MakeParameters(args, settings);
			Assert.AreEqual(new MakeZip ().MakeZipEntryName (p,
				joinPathSegments(basePath, "app.config")), "app.config");
			Assert.AreEqual(new MakeZip ().MakeZipEntryName (p, 
				joinPathSegments(basePath, "bin", "Release", "nunit.framework.dll")), 
				joinPathSegments("bin", "Release", "nunit.framework.dll"));
		}
예제 #4
0
		public void TestCase_MakeParameters_strings ()
		{
			// Init settings for this testcase.
			NameValueCollection settings = newSettingsWithBasePath (getProjectDirectoryPath ());

			Assert.Throws<ArgumentException> (() => {
				new MakeZip().MakeParameters(new string[0], settings);
			}, "Number of argument must be 4.");
			Assert.Throws<ArgumentException> (() => {
				new MakeZip().MakeParameters(new string[1], settings);
			}, "Number of argument must be 4.");
			Assert.Throws<ArgumentException> (() => {
				new MakeZip().MakeParameters(new string[2], settings);
			}, "Number of argument must be 4.");
			Assert.Throws<ArgumentException> (() => {
				new MakeZip().MakeParameters(new string[3], settings);
			}, "Number of argument must be 4.");
			Assert.Throws<ArgumentException> (() => {
				new MakeZip().MakeParameters(new string[4], settings);
			}, "All of arguments must be not null.");
			Assert.Throws<ArgumentException> (() => {
				new MakeZip().MakeParameters(new string[]{"jid", "pid", "*.foo", "app.config"}, settings);
			}, "Target file(s) must exist.");
			Assert.Throws<ArgumentException> (() => {
				new MakeZip().MakeParameters(new string[]{"jid", "pid", "*.config", "app.config"}, settings);
			}, "Zip file must not exist.");

			string[] args = { "jid", "pid", "*.config", "hello.zip" };
			Parameters p = new MakeZip().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(), "*.config"),
				"3rd argument must became target file path.");
			Assert.AreEqual (p.ZipFilePath, 
				joinPathSegments(getProjectDirectoryPath(), "hello.zip"),
				"4th argument must became zip file path.");

		}
예제 #5
0
		public void TestCase_MakeZipFile_Parameters ()
		{
			string basePath = getProjectDirectoryPath();
			string zipFullPath = joinPathSegments(basePath, "hello.zip");
			string[] args = { "jid", "pid", "*.config", "hello.zip" };
			NameValueCollection settings = newSettingsWithBasePath (basePath);
			Parameters p = new MakeZip().MakeParameters(args, settings);

			new MakeZip ().MakeZipFile (p);

			Assert.True (File.Exists (zipFullPath));

			using (var zf = ZipFile.Open (p.ZipFilePath, ZipArchiveMode.Read)) {
				IList<string> configFileNames = new string[] {"app.config", "packages.config"};
				foreach (ZipArchiveEntry e in zf.Entries) {
					Assert.True (configFileNames.Contains (e.FullName), 
						string.Format("Invalid zip archive entry \"{0}\".", e.FullName));
				}
			}
		}