public void ShouldCreateAnInstanceOfFileOutputChannelWhenOutputSettingIsTypeOfFileOutputSetting() { // arrange OutputSetting consoleSetting = new FileOutputSetting(); // act IStatsOutputChannel actual = new OutputChannelFactory().CreateOutputChannelInstance(consoleSetting); // assert Assert.IsInstanceOf(typeof(FileOutputChannel), actual); }
static void Main(string[] args) { string pathToConfig = args.Length > 0 ? args[0] : Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "healthMonitoring.config"); // Load settings IFileManager fileManager = new FileManager(); ISettingLoader loader = new SettingLoader(fileManager); HealthMonitoringSetting setting = loader.Parse(pathToConfig); IStatsCheckerFactory statsCheckerFactory = new StatsCheckerFactory(); IOutputChannelFactory outputChannelFactory = new OutputChannelFactory(); IStatsTemplate template = new BasicStatsTemplate(); ConcurrentQueue<Exception> exceptions = new ConcurrentQueue<Exception>(); Parallel.For(0, setting.Clients.Length, (i, loopState) => { try { Controller controller = new Controller(setting.Clients[i], statsCheckerFactory, outputChannelFactory, template); controller.Start(); } catch(Exception ex) { exceptions.Enqueue(ex); } }); // Throw the exceptions here after the loop completes. if (exceptions.Count > 0) throw new AggregateException(exceptions); Thread.Sleep(Timeout.Infinite); }