Beispiel #1
0
        public StageRunnerTests()
        {
            IList<IStage> stages = new List<IStage>();

            // create stage mocks
            for (int i = 0; i < 10; i++)
            {
                Mock<IStage> mock = new Mock<IStage>();

                // increment counter when Run is called
                mock.Setup(stage => stage.Run()).Callback(() => stagesStarted++);
                mock.Setup(stage => stage.Weight).Returns(1.0);

                stageMocks.Add(mock);
                stages.Add(mock.Object);
            }

            // create the runner
            runner = new StageRunner("nowhere", stages, tokenSource.Token);
        }
Beispiel #2
0
        /// <summary>
        /// Runs the report generation.
        /// </summary>
        /// <param name="cancellationToken">cancellation token which cancels the operation</param>
        /// <param name="rootPath">path to the pre-created directory into which all the report files should be added</param>
        /// <param name="archiveFilename">set to non-null string to override the default archive file name</param>
        /// <param name="cleanup">set to false, if you want Shtirlitz to leave the raw files in place. To ease the debugging, for example.</param>
        /// <returns>file name of the created archive</returns>
        private string RunInternal(CancellationToken cancellationToken, string rootPath, string archiveFilename, bool cleanup = true)
        {
            // build stage list
            List<IStage> stages = new List<IStage>();

            // start with report generation
            foreach (IReporter reporter in reporters)
            {
                stages.Add(new ReporterStage(rootPath, reporter, cancellationToken));
            }

            // then archive all the files
            stages.Add(new ArchiverStage(rootPath, archiveFilename, archiver, cancellationToken));

            // then clean the original temporary directory up
            if (cleanup)
            {
                stages.Add(new CleanupStage(rootPath, cancellationToken));
            }

            // then send the archive file
            foreach (ISender sender in senders)
            {
                stages.Add(new SenderStage(archiveFilename, sender, cancellationToken));
            }

            // pack all the stages into the stage runner
            StageRunner runner = new StageRunner(rootPath, stages, cancellationToken, "Everything");

            // subscribe to the progress updates on a runner
            runner.Progress += RaiseGenerationProgress;

            // start report generation
            runner.Run();

            // unsubscribe from progress update on a runner
            runner.Progress -= RaiseGenerationProgress;

            return archiveFilename;
        }