public void ShouldThrowExceptionWhenServiceTypeRequestedDoesntExist()
		{
			// arrange
			StatsCheckerFactory factory = new StatsCheckerFactory();
			ClientSetting setting = new ClientSetting
			{
				AssemblyName = "Rbi.Property.HealthMonitoring.Tests",
				FullQualifiedServiceName = "Rbi.Property.HealthMonitoring.Tests.StatsCheckers.DummyType"
			};

			// act
			Assert.Throws<Exception>(() => factory.CreateStatsCheckerInstance(setting));
		}
		public void ShouldCreateBasicHttpCheckerWhenItsTypeIsRequested()
		{
			// arrange
			StatsCheckerFactory factory = new StatsCheckerFactory();
			ClientSetting setting = new ClientSetting
			{
				AssemblyName = "Rbi.Property.HealthMonitoring",
				FullQualifiedServiceName = "Rbi.Property.HealthMonitoring.StatsCheckers.BasicHttpStatsChecker"
			};

			// act
			IChecker actual = factory.CreateStatsCheckerInstance(setting);
			
			Assert.IsInstanceOf(typeof(BasicHttpStatsChecker), actual);
		}
		public Controller(ClientSetting clientSetting, IStatsCheckerFactory statsCheckerFactory, IOutputChannelFactory outputChannelFactory, IStatsTemplate template)
		{
			this.clientSetting = clientSetting;
			// If enabled then start immedially
			statsChecker = statsCheckerFactory.CreateStatsCheckerInstance(clientSetting);
			statsOutputChannels = clientSetting.Outputs.Select(output => outputChannelFactory.CreateOutputChannelInstance(output, output, template)).ToArray();

			timer = new Timer
			{
				Enabled = clientSetting.Enabled,
				Interval = clientSetting.Ping.Interval
			};

			timer.Elapsed += (sender, e) => Ping(sender, e, clientSetting.Ping);
		}
		public IChecker CreateStatsCheckerInstance(ClientSetting setting)
		{
			Type[] allTypesInAssembly = Assembly.Load(setting.AssemblyName).GetTypes();
			Type serviceInterface = typeof(IChecker);
			Type serviceType = allTypesInAssembly.FirstOrDefault
			(
				 typeInAssembly => 
					 typeInAssembly.FullName == setting.FullQualifiedServiceName &&
					 serviceInterface.IsAssignableFrom(typeInAssembly)
			);

			if (serviceType == null)
			{
				throw new Exception(string.Format("The service type {0} is either not found in given assembly or doesn't implement interface {1}", setting.FullQualifiedServiceName, serviceInterface));
			}

			return Activator.CreateInstance(serviceType) as IChecker;
		}
		public void Playground()
		{
			ClientSetting clientSetting = new ClientSetting
			{
				Enabled = true,
				Name = "local api",
				Ping = new PingSetting
				{
					Interval = 5000
				}
			};

			Controller controller = new Controller(clientSetting, null, null, null);

			controller.Start();

			Thread.Sleep(Timeout.Infinite);
		}