public void CompressedAndDecompressedFilesAreEqual()
        {
            jobBatchOrchestrator.ShouldNotBeNull();
            var thread = new Thread(() => jobBatchOrchestrator.StartProcess(new JobDescription
            {
                InputFile  = inputFile,
                OutputFile = outputFile,
                Operation  = Operation.Compress
            }));

            thread.Start();
            thread.Join();

            var jobContext = serviceProvider.GetService <IJobContext>();

            jobContext.Result.ShouldBe(ExecutionResult.Success);

            thread = new Thread(() => jobBatchOrchestrator.StartProcess(new JobDescription
            {
                InputFile  = outputFile,
                OutputFile = decompressedFile,
                Operation  = Operation.Decompress
            }));

            thread.Start();
            thread.Join();

            jobContext.Result.ShouldBe(ExecutionResult.Success);
            outputFile.Refresh();
            decompressedFile.Refresh();

            outputFile.Length.ShouldNotBeNull();
            inputFile.Length.ShouldBe(decompressedFile.Length);

            inputFile.ShouldHaveSameContentAs(decompressedFile);
        }
Exemple #2
0
        public void Run(string[] args)
        {
            logger.LogInformation($"Application started with {string.Join(",", args)}");
            var validationResult = commandLineValidator.Validate(args);

            if (!validationResult.IsValid)
            {
                logger.LogInformation(
                    $"invalid command line arguments {string.Join(Environment.NewLine, validationResult.Errors)}");
                PrintHelp();
                return;
            }

            var jobDescription = argumentsParser.Parse(args);

            jobBatchOrchestrator.StartProcess(jobDescription);
            logger.LogInformation(jobContext.Result == ExecutionResult.Failure
                ? $"Failed to process file due to an error: {jobContext.Error} reported by {jobContext.ReportedBy}"
                : $"Completed file in {jobContext.ElapsedTimeMilliseconds} ms");
            void PrintHelp() => logger.LogInformation(Constants.Help);
        }