public void ReportsBasicRuntimeStatistics() { var container = new WindsorContainer(); container.Register( Component.For<IServiceHost>().Forward<MultitaskingServiceHost>().Instance(new MultitaskingServiceHost())); container.Register(Component.For<IHostedService>().Forward<FakeHostedService>().Instance(new FakeHostedService())); var runtime = new BasicFabric(container); var settings = new FabricRuntimeSettings(); settings.ServiceHost.WithDefault(typeof(MultitaskingServiceHost)); settings.HostedServices.WithDefault(new List<Type> { typeof(FakeHostedService) }); runtime.Initialize(settings); runtime.Start(); Assert.AreEqual(FabricRuntimeState.Started, runtime.State); Assert.AreEqual(FabricRuntimeState.Started, runtime.GetStatistics().RuntimeState); Assert.AreEqual(typeof(MultitaskingServiceHost), runtime.GetStatistics().ConfiguredServiceHost); Assert.AreEqual(typeof(FakeHostedService), runtime.GetStatistics().ConfiguredHostedServices[0]); }
public void ReportsErrorsThrownByHostedServices() { var container = new WindsorContainer(); container.Register( Component.For<IServiceHost>().Forward<MultitaskingServiceHost>().Instance(new MultitaskingServiceHost())); container.Register( Component.For<IHostedService>().Forward<FailingHostedService>().Instance(new FailingHostedService())); var runtime = new BasicFabric(container); var settings = new FabricRuntimeSettings(); settings.ServiceHost.WithDefault(typeof(MultitaskingServiceHost)); settings.HostedServices.WithDefault(new List<Type> { typeof(FailingHostedService) }); runtime.Initialize(settings); runtime.Start(); Assert.AreEqual(FabricRuntimeState.Started, runtime.State); Thread.Sleep(100); // let the exception have a chance to be thrown and caught var exceptions = runtime.GetExceptionsThrownByHostedServices(); Assert.AreEqual(1, exceptions.Count); }
public void ThrowsWhenHostedServiceNotResolvable() { var container = new WindsorContainer(); container.Register( Component.For<IServiceHost>().Forward<MultitaskingServiceHost>().Instance(new MultitaskingServiceHost())); var runtime = new BasicFabric(container); var settings = new FabricRuntimeSettings(); settings.ServiceHost.WithDefault(typeof(MultitaskingServiceHost)); settings.HostedServices.WithDefault(new List<Type> { GetType() }); runtime.Initialize(settings); runtime.Start(); }