예제 #1
0
		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]);
		}
예제 #2
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);
		}
예제 #3
0
		public void ErrorFreeWithValidConfig()
		{
			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);
		}
예제 #4
0
		public void ThrowsWhenServiceHostNotResolvable()
		{
			var container = new WindsorContainer();

			var runtime = new BasicFabric(container);

			var settings = new FabricRuntimeSettings();

			settings.ServiceHost.WithDefault(GetType());
			settings.HostedServices.WithDefault(new List<Type> { GetType() });

			runtime.Initialize(settings);
		}
예제 #5
0
		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();
		}
예제 #6
0
		public void ThrowsWhenConfigIsMissingServiceHost()
		{
			var container = new WindsorContainer();

			var runtime = new BasicFabric(container);

			var settings = new FabricRuntimeSettings();

			settings.HostedServices.WithDefault(new List<Type>());

			runtime.Initialize(settings);
		}
예제 #7
0
		public void ThrowsWhenConfigIsEmpty()
		{
			var container = new WindsorContainer();

			var runtime = new BasicFabric(container);

			runtime.Initialize(new FabricRuntimeSettings());
		}