public void Setup()
        {
            compressedFileKey = "compressed-file";

            flatZipFile = true;

            request = new Request("origin-bucket", "origin-resource", "destination-bucket", compressedFileKey, flatZipFile);

            files = new []
            {
                new FileResponse("file-0", contentStream: new MemoryStream()),
                new FileResponse("file-1", contentStream: new MemoryStream()),
                new FileResponse("file-2", contentStream: new MemoryStream()),
                new FileResponse("file-3", contentStream: new MemoryStream()),
            };

            compressedFile = new FileResponse(compressedFileKey, contentStream: new MemoryStream());

            url = "s3.com/compressed-file";

            cancellationToken = CancellationToken.None;

            fileRetriever = Substitute.For <IFileRetriever>();
            fileRetriever.RetrieveToMemory(request.OriginBucketName, request.OriginResourceName, Arg.Any <string>(), cancellationToken).Returns(files);

            fileZipper = Substitute.For <IFileZipper>();
            fileZipper.Compress(compressedFileKey, files, flatZipFile, cancellationToken).Returns(compressedFile);

            fileUploader = Substitute.For <IFileUploader>();
            fileUploader.Upload("destination-bucket", compressedFileKey, compressedFile, cancellationToken).Returns(url);

            service = new Service(fileRetriever, fileZipper, fileUploader);
        }
Example #2
0
        public FileParserTests()
        {
            _fileRetriever = _fixture.Freeze <IFileRetriever>();
            _csvParser     = _fixture.Freeze <ICsvRowParser>();

            _sut = _fixture.Create <FileParser>();
        }
Example #3
0
 /// <summary>
 /// New instance
 /// </summary>
 /// <param name="work"></param>
 /// <param name="fileSaver"></param>
 /// <param name="fileRetriever"></param>
 public ProgramsController(IProgramsUnitOfWork work, IFileSaver fileSaver, IFileRetriever fileRetriever)
 {
     this.fileSaver       = fileSaver;
     this.fileRetriever   = fileRetriever;
     this.telemetryClient = new TelemetryClient();
     this.Work            = work;
 }
        public Service(IFileRetriever fileRetriever, IFileZipper fileZipper, IFileUploader fileUploader)
        {
            this.fileRetriever = fileRetriever;
            this.fileZipper    = fileZipper;
            this.fileUploader  = fileUploader;

            this.log = LogProvider.GetCurrentClassLogger();
        }
        public void SetUp()
        {
            _helper = new EnumerableHelper();

            _mocks = new MockRepository();

            _fileRetriever = _mocks.StrictMock<IFileRetriever>();
            _ruleRetriever = _mocks.StrictMock<IRuleRetriever>();
            _ruleRunner = new RuleRunner(_fileRetriever, _ruleRetriever);
        }
        public async Task <byte[]> GetPackage(int packageId, IFileRetriever fileRetriever)
        {
            ProgramPackageInfo pkg = await this.telimenaPortalContext.ProgramPackages.FirstOrDefaultAsync(x => x.Id == packageId).ConfigureAwait(false);

            if (pkg != null)
            {
                return(await fileRetriever.GetFile(pkg, this.containerName).ConfigureAwait(false));
            }

            return(null);
        }
Example #7
0
        public async Task <byte[]> GetPackage(Guid packageId, IFileRetriever fileRetriever)
        {
            ProgramUpdatePackageInfo pkg = await this.GetUpdatePackageInfo(packageId).ConfigureAwait(false);

            if (pkg != null)
            {
                return(await fileRetriever.GetFile(pkg, this.containerName).ConfigureAwait(false));
            }

            return(null);
        }
Example #8
0
        public S3ZipSharp(Config config, ILogger logger)
        {
            if (config is null)
            {
                throw new ArgumentNullException(nameof(config));
            }


            this.config         = config;
            this._logger        = logger;
            this._s3ClientProxy = new S3ClientProxy(new Amazon.S3.AmazonS3Client(config.AccessKeyId, config.SecretAccessKey, RegionEndpoint.APSoutheast2), config.BatchSize, _logger);
        }
Example #9
0
        public async Task <byte[]> GetPackage(int toolkitDataId, IFileRetriever fileRetriever)
        {
            TelimenaToolkitData toolkitData = await this.TelimenaPortalContext.TelimenaToolkitData.FirstOrDefaultAsync(x => x.Id == toolkitDataId).ConfigureAwait(false);

            TelimenaPackageInfo pkg = toolkitData?.TelimenaPackageInfo;

            if (pkg != null)
            {
                return(await fileRetriever.GetFile(pkg, this.containerName).ConfigureAwait(false));
            }

            return(null);
        }
Example #10
0
 /// <summary>
 /// New instance
 /// </summary>
 /// <param name="work"></param>
 /// <param name="fileSaver"></param>
 /// <param name="fileRetriever"></param>
 public UpdatersController(IToolkitDataUnitOfWork work, IFileSaver fileSaver, IFileRetriever fileRetriever)
 {
     this.work          = work;
     this.fileSaver     = fileSaver;
     this.fileRetriever = fileRetriever;
 }
Example #11
0
 /// <summary>
 /// New instance
 /// </summary>
 /// <param name="work"></param>
 /// <param name="fileSaver"></param>
 /// <param name="fileRetriever"></param>
 public ProgramsController(IProgramsUnitOfWork work, IFileSaver fileSaver, IFileRetriever fileRetriever)
 {
     this.fileSaver     = fileSaver;
     this.fileRetriever = fileRetriever;
     this.Work          = work;
 }
Example #12
0
 /// <summary>
 /// New instance
 /// </summary>
 /// <param name="work"></param>
 /// <param name="fileSaver"></param>
 /// <param name="fileRetriever"></param>
 public UpdatePackagesController(IProgramsUnitOfWork work, IFileSaver fileSaver, IFileRetriever fileRetriever, IFileRemover fileRemover)
 {
     this.FileRetriever = fileRetriever;
     this.work          = work;
     this.fileSaver     = fileSaver;
     this.fileRemover   = fileRemover;
 }
Example #13
0
        public S3ClientProxyTests()
        {
            var mockClient = new S3ClientMock().GetMockedClient();

            s3Proxy = new S3ClientProxy(mockClient, 10, null);
        }
        public static async Task <IHttpActionResult> GetDownloadLatestProgramPackageResponse(IProgramsUnitOfWork unitOfWork, int programId, IFileRetriever fileRetriever)
        {
            ProgramPackageInfo packageInfo = await unitOfWork.ProgramPackages.GetLatestProgramPackageInfo(programId).ConfigureAwait(false);

            byte[] bytes = await unitOfWork.ProgramPackages.GetPackage(packageInfo.Id, fileRetriever).ConfigureAwait(false);

            HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(bytes)
            };

            result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
            {
                FileName = packageInfo.FileName
            };
            result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

            return(new ResponseMessageResult(result));
        }
 /// <summary>
 /// New instance
 /// </summary>
 /// <param name="work"></param>
 /// <param name="fileSaver"></param>
 /// <param name="fileRetriever"></param>
 public UpdatePackagesController(IProgramsUnitOfWork work, IFileSaver fileSaver, IFileRetriever fileRetriever, IFileRemover fileRemover, TelemetryClient telemetryClient)
 {
     this.FileRetriever   = fileRetriever;
     this.work            = work;
     this.fileSaver       = fileSaver;
     this.fileRemover     = fileRemover;
     this.telemetryClient = telemetryClient;
 }
Example #16
0
 public FileParser(ICsvRowParser csvRowParser, IFileRetriever fileRetriever)
 {
     _csvRowParser  = csvRowParser;
     _fileRetriever = fileRetriever;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProgramManagementController"/> class.
 /// </summary>
 /// <param name="work">The work.</param>
 public ProgramManagementController(IProgramsUnitOfWork work, IFileRetriever fileRetriever)
 {
     this.Work          = work;
     this.fileRetriever = fileRetriever;
 }
Example #18
0
 public RuleRunner(IFileRetriever fileRetriever, IRuleRetriever ruleRetriever)
 {
     _fileRetriever = fileRetriever;
     _ruleRetriever = ruleRetriever;
 }