Example #1
0
		public void ZipDirectory_ReleasesLockOnZipFile()
		{
			var fixture = new Fixture();
			string sourceDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
			Directory.CreateDirectory(sourceDirectory);
			string sourceFile1 = Path.Combine(sourceDirectory, Guid.NewGuid().ToString() + ".tmp");
			File.WriteAllText(sourceFile1, fixture.Create<string>());
			string sourceFile2 = Path.Combine(sourceDirectory, Guid.NewGuid().ToString() + ".tmp");
			File.WriteAllText(sourceFile2, fixture.Create<string>());

			string zipFilePath = Path.Combine(sourceDirectory, Guid.NewGuid().ToString() + ".zip");
			try
			{

				var sut = new Zipper(new Mock<ILog>().Object);
				sut.ZipDirectory(sourceDirectory, zipFilePath);
				File.Delete(zipFilePath);
			}
			finally
			{
				try 
				{
					Directory.Delete(sourceDirectory, true);
				}
				catch {}

				try
				{
					File.Delete(zipFilePath);
				}
				catch { }
			}
		}
Example #2
0
		public void ZipFile_ReleasesLockOnZipFile()
		{
			var fixture = new Fixture();
			string sourceFilePath = Path.GetTempFileName();
			string zipFilePath = Path.ChangeExtension(sourceFilePath, ".zip");
			File.WriteAllText(sourceFilePath, fixture.Create<string>());
			try 
			{

				var sut = new Zipper(new Mock<ILog>().Object);
				sut.ZipFile(sourceFilePath, zipFilePath);
				File.Delete(zipFilePath);
			}
			finally
			{
				try 
				{
					File.Delete(sourceFilePath);
				}
				catch {}

				try 
				{
					File.Delete(zipFilePath);
				}
				catch {}
			}
		}