public void before_all() { // setup _command = new NewCommand(); _fileSystem = new FileSystem(); _zipService = new ZipFileService(_fileSystem); _commandInput = new NewCommandInput(); tmpDir = FileSystem.Combine("Templating", Guid.NewGuid().ToString()); repoZip = FileSystem.Combine("Templating", "repo.zip"); _zipService.ExtractTo(repoZip, tmpDir, ExplodeOptions.DeleteDestination); solutionFile = FileSystem.Combine("Templating", "sample", "myproject.txt"); oldContents = _fileSystem.ReadStringFromFile(solutionFile); solutionDir = _fileSystem.GetDirectory(solutionFile); _commandInput.GitFlag = "file:///{0}".ToFormat(_fileSystem.GetFullPath(tmpDir).Replace("\\", "/")); _commandInput.ProjectName = "MyProject"; _commandInput.SolutionFlag = solutionFile; _commandInput.OutputFlag = solutionDir; _commandInput.RakeFlag = "init.rb"; _commandResult = _command.Execute(_commandInput); newSolutionContents = _fileSystem.ReadStringFromFile(solutionFile); }
public void SetUp() { var assembly = typeof (AssemblyPackageMarker).Assembly; var stream = assembly.GetManifestResourceStream(typeof (AssemblyPackageMarker), "pak-data.zip"); var service = new ZipFileService(); service.ExtractTo("description of this", stream, "package-data"); // These 3 files should be in the zip file embedded within the AssemblyPackage assembly File.Exists(Path.Combine("package-data", "1.txt")).ShouldBeTrue(); File.Exists(Path.Combine("package-data", "2.txt")).ShouldBeTrue(); ; File.Exists(Path.Combine("package-data", "3.txt")).ShouldBeTrue(); ; }
public static IEnumerable<string> GetFilesInZip(string zipFileName) { var tempPath = Path.GetTempPath(); var zipDirectory = Path.Combine(tempPath, "zip-contents"); if (Directory.Exists(zipDirectory)) { Directory.Delete(zipDirectory, true); } Directory.CreateDirectory(zipDirectory); var zfs = new ZipFileService(new FileSystem()); zfs.ExtractTo(zipFileName, zipDirectory, ExplodeOptions.DeleteDestination); return Directory.GetFiles(zipDirectory, "*", SearchOption.AllDirectories).Select( x => x.PathRelativeTo(zipDirectory)); }