public void before_each()
 {
     _command = new NewCommand();
     _fileSystem = new FileSystem();
     _zipService = new ZipFileService(_fileSystem);
     _commandInput = new NewCommandInput();
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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(); ;
        }
Esempio n. 4
0
        public void create_test_zip_to_a_nonexistent_path()
        {
            var fileSystem = new FileSystem();
            fileSystem.DeleteDirectory(".\\nonexist");

            fileSystem.FileExists(".\\nonexist\\silly.zip").ShouldBeFalse();

            fileSystem.WriteStringToFile(".\\bob.txt","hi");
            var service = new ZipFileService(fileSystem);
            service.CreateZipFile(".\\nonexist\\silly.zip", f=>
            {
                f.AddFile(".\\bob.txt","");
            });

            fileSystem.FileExists(".\\nonexist\\silly.zip").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));
        }
Esempio n. 6
0
        public void read_version_out_of_a_zip_file()
        {
            var versionFile = Path.Combine(Path.GetTempPath(), BottleFiles.VersionFile);
            var guid = Guid.NewGuid();
            new FileSystem().WriteStringToFile(versionFile, guid.ToString());

            if (File.Exists("zip1.zip"))
            {
                File.Delete("zip1.zip");
            }

            using (var zip1 = new ZipFile("zip1.zip"))
            {
                zip1.AddFile(versionFile, "");
                zip1.Save();
            }

            var service = new ZipFileService(new FileSystem());

            service.GetVersion("zip1.zip").ShouldEqual(guid);
        }