public void invoke_event_if_we_failed_to_start_service_during_check()
        {
            var service = Substitute.For <IApplicationService, IGuardedService>();

            ((IGuardedService)service).IsRunning.Returns(false);
            var okService = Substitute.For <IApplicationService>();
            var locator   = Substitute.For <IContainer>();

            locator.ResolveAll <IApplicationService>().Returns(new[] { service, okService });
            var settingsRepos = Substitute.For <ISettingsRepository>();

            settingsRepos.IsEnabled(Arg.Any <Type>()).Returns(true);
            ApplicationServiceFailedEventArgs actual = null;

            var sut = new ApplicationServiceManager(locator);

            sut.Settings            = settingsRepos;
            sut.CheckInterval       = TimeSpan.FromMilliseconds(100);
            sut.StartInterval       = TimeSpan.FromMilliseconds(100);
            sut.ServiceStartFailed += (o, e) => actual = e;
            sut.Start();
            service.When(x => x.Start()).Do(x => { throw new InvalidOperationException(); });
            Thread.Sleep(200);

            actual.Should().NotBeNull();
            actual.ApplicationService.Should().Be(service);
            actual.Exception.Should().BeOfType <InvalidOperationException>();
        }
 private void OnServiceFailed(object sender, ApplicationServiceFailedEventArgs e)
 {
     _log.Error("Failed to execute " + e.ApplicationService, e.Exception);
     try
     {
         Err.Report(e.Exception, new { JobType = e.ApplicationService?.GetType().FullName });
     }
     catch (Exception exception)
     {
         _log.Error("Failed to report.", exception);
     }
 }
Esempio n. 3
0
 private void OnServiceFailed(object sender, ApplicationServiceFailedEventArgs e)
 {
     _log.Error("Failed to execute " + e.ApplicationService, e.Exception);
 }
Esempio n. 4
0
 private void OnApplicationFailure(object sender, ApplicationServiceFailedEventArgs e)
 {
     Console.WriteLine(e.ApplicationService + " failed: " + e.Exception);
 }
Esempio n. 5
0
 private void OnServiceFailed(object sender, ApplicationServiceFailedEventArgs e)
 {
 }