/// <summary>
    /// Returns a file system implementation, which is assigned
    /// to the <see cref="TestContext.FileSystem"/> property.
    /// </summary>
    /// <param name="localTestFolder">The temporary test folder that is
    /// used by the context. This is actually just the <see cref="TestContext.LocalTestRoot"/>
    /// reference.</param>
    protected override IFileSystemProvider InitFileSystem(DirectoryInfo localTestFolder)
    {
      //init empty zip file
      ZipFilePath = Path.Combine(localTestFolder.FullName, "TestArchive.zip");
      var zip = new ZipFile(ZipFilePath);
      zip.Save();
      zip.Dispose();

      //init transfer stores
      var downloadTransferStore = new TestTransferStore<ZipDownloadTransfer>();
      var uploadTransferStore = new TestTransferStore<ZipUploadTransfer>();

      //init configuration
      var tempFactory = new TempFileStreamFactory(LocalTestRoot.FullName);

      var zipFile = new FileInfo(ZipFilePath);

      var configuration = new ZipFileSystemConfiguration(zipFile, tempFactory);
      configuration.RootName = "Test Root";
      configuration.DownloadStore = downloadTransferStore;
      configuration.UploadStore = uploadTransferStore;
      configuration.DownloadTokenExpirationTime = TimeSpan.FromHours(24);
      configuration.UploadTokenExpirationTime = TimeSpan.FromHours(24);
      configuration.DefaultDownloadBlockSize = 32768;
      configuration.MaxDownloadBlockSize = 32768 * 2;
      configuration.MaxUploadBlockSize = 32768 * 4;
      configuration.MaxUploadFileSize = (long)1024 * 1024 * 2048; //2GB limit



      //create provider
      Provider = new ZipFileProvider(configuration);
      return Provider;
    }
示例#2
0
        /// <summary>
        /// Creates the provider with the ZIP file to be processed.
        /// 注意:所有目录 必须以‘/’结尾
        /// </summary>
        public ZipFileProvider(ZipFileSystemConfiguration configuration) {
            Ensure.ArgumentNotNull(configuration, "configuration");
            Configuration = configuration;

            //init the repository
            NodeRepository = new ZipNodeRepository(configuration);

            InitTransferServices();
        }
    /// <summary>
    /// Creates a browser for a given zip file.
    /// </summary>
    /// <param name="configuration">Represents the processed ZIP file.</param>
    /// <exception cref="ArgumentNullException">If <paramref name="configuration"/> is a
    /// null reference.</exception>
    public ZipNodeRepository(ZipFileSystemConfiguration configuration)
    {
      if(configuration == null)
      {
        throw new ArgumentNullException("configuration");
      }

      Configuration = configuration;

      //create and immediately parse the ZIP file into a repository
      ZipFile = new ZipFile(configuration.ZipFileInfo.FullName);
      Refresh();
    }
示例#4
0
        public void Init()
        {
            //init temp folder
            TempDirectory = TestUtil.CreateTestDirectory();

            //create copy of test ZIP file within temp folder
            string path = Path.Combine(TempDirectory.FullName, "TestFile.zip");

            File.WriteAllBytes(path, Resources.TestFile);
            TestZipFile = new FileInfo(path);

            //init transfer stores
            InMemoryTransferStore <ZipDownloadTransfer> DownloadTransferStore = new InMemoryTransferStore <ZipDownloadTransfer>();
            InMemoryTransferStore <ZipUploadTransfer>   UploadTransferStore   = new InMemoryTransferStore <ZipUploadTransfer>();

            //init configuration
            var tempFactory   = new TempFileStreamFactory(TempDirectory.FullName);
            var configuration = new ZipFileSystemConfiguration(TestZipFile, tempFactory);

            configuration.RootName      = "Test Root";
            configuration.DownloadStore = DownloadTransferStore;
            configuration.UploadStore   = UploadTransferStore;
            configuration.DownloadTokenExpirationTime = TimeSpan.FromHours(24);
            configuration.UploadTokenExpirationTime   = TimeSpan.FromHours(24);
            configuration.DefaultDownloadBlockSize    = 32768;
            configuration.MaxDownloadBlockSize        = 32768 * 2;
            configuration.MaxUploadBlockSize          = 32768 * 4;

            AdjustFileSystemConfiguration(configuration);
            FileSystemConfiguration = configuration;

            //create provider
            Provider = new ZipFileProvider(FileSystemConfiguration);

            InitInternal();
        }
        /// <summary>
        /// Returns a file system implementation, which is assigned
        /// to the <see cref="TestContext.FileSystem"/> property.
        /// </summary>
        /// <param name="localTestFolder">The temporary test folder that is
        /// used by the context. This is actually just the <see cref="TestContext.LocalTestRoot"/>
        /// reference.</param>
        protected override IFileSystemProvider InitFileSystem(DirectoryInfo localTestFolder)
        {
            //init empty zip file
            ZipFilePath = Path.Combine(localTestFolder.FullName, "TestArchive.zip");
            var zip = new ZipFile(ZipFilePath);

            zip.Save();
            zip.Dispose();

            //init transfer stores
            var downloadTransferStore = new TestTransferStore <ZipDownloadTransfer>();
            var uploadTransferStore   = new TestTransferStore <ZipUploadTransfer>();

            //init configuration
            var tempFactory = new TempFileStreamFactory(LocalTestRoot.FullName);

            var zipFile = new FileInfo(ZipFilePath);

            var configuration = new ZipFileSystemConfiguration(zipFile, tempFactory);

            configuration.RootName      = "Test Root";
            configuration.DownloadStore = downloadTransferStore;
            configuration.UploadStore   = uploadTransferStore;
            configuration.DownloadTokenExpirationTime = TimeSpan.FromHours(24);
            configuration.UploadTokenExpirationTime   = TimeSpan.FromHours(24);
            configuration.DefaultDownloadBlockSize    = 32768;
            configuration.MaxDownloadBlockSize        = 32768 * 2;
            configuration.MaxUploadBlockSize          = 32768 * 4;
            configuration.MaxUploadFileSize           = (long)1024 * 1024 * 2048; //2GB limit



            //create provider
            Provider = new ZipFileProvider(configuration);
            return(Provider);
        }
示例#6
0
 /// <summary>
 /// Allows to make adjustments to the configuration that is being
 /// used to construct the provider.
 /// </summary>
 /// <param name="configuration">The preconfigured configuration.</param>
 protected virtual void AdjustFileSystemConfiguration(ZipFileSystemConfiguration configuration)
 {
 }