示例#1
0
        private static OptionGroup CreateRunner(IClientFactory clientFactory)
        {
            var schedulerWaiter = new SchedulerWaiter(clientFactory.RestClientForJobServer,
                                                      new AutoResetEventBoundary(), new TimerFactory(),
                                                      new JobRunStatusPresenter(new PresenterMessagePresenter()));
            var processExecutor     = new ProcessExecutor(() => new ProcessBoundary());
            var environment         = new EnvironmentBoundary();
            var fileSystemCommands  = new FileSystemCommandsBoundary();
            var fileSystem          = new FileSystem(environment, fileSystemCommands);
            var serviceStatusWaiter = new ServiceStatusWaiter("waiting for service status",
                                                              new AutoResetEventBoundary(), new TimerFactory(),
                                                              new ServiceStatusProvider(processExecutor, fileSystem));
            // all options available

            var root = CreateRootGroup(clientFactory, schedulerWaiter, fileSystemCommands, processExecutor, fileSystem,
                                       serviceStatusWaiter, environment);

            Logger.Debug("Running application");
            return(root);
        }
示例#2
0
        public void Exception_ShouldSetAutoresetEventAndFail()
        {
            var jobServer = new Mock <IJobServer>();

            jobServer.Setup(s => s.GetJobRunStatus(It.IsAny <Guid>(), It.IsAny <int>())).Throws <HttpRequestException>();
            var autoResetEvent   = new FakeAutoResetEvent();
            var fakeTimerFactory = new FakeTimerFactory();

            var waiter = new SchedulerWaiter(() => jobServer.Object, autoResetEvent, fakeTimerFactory, new FakeMessagePresenter());

            autoResetEvent.WhatToDoDuringWaitOne = () =>
            {
                fakeTimerFactory.FireTimerAction();
            };

            var result = waiter.WaitForTaskToComplete(JobRunStatus.Create("sample task"));

            result.Result.IsSuccess.Should().BeFalse("because an exception was thrown by the scheduler");
            result.Result.FailureDescription.Should()
            .NotBeEmpty("because it should contain a description of what happened");
        }