public void Construct() { var loggerMock = new Mock<ILogger>(); var brokerMock = new Mock<IMessageBroker>(); var dataStoreMock = new Mock<IDataStore>(); var context = new TabSetupContext(loggerMock.Object, brokerMock.Object, ()=>dataStoreMock.Object); Assert.Equal(loggerMock.Object, context.Logger); Assert.Equal(brokerMock.Object, context.MessageBroker); Assert.Equal(dataStoreMock.Object, context.GetTabStore()); }
/// <summary> /// Initializes this instance of the Glimpse runtime. /// </summary> /// <returns> /// <c>true</c> if system initialized successfully, <c>false</c> otherwise /// </returns> public bool Initialize() { var policy = RuntimePolicy.Off; // Double checked lock to ensure thread safety. http://en.wikipedia.org/wiki/Double_checked_locking_pattern if (!IsInitialized) { lock (LockObj) { if (!IsInitialized) { var logger = Configuration.Logger; policy = DetermineAndStoreAccumulatedRuntimePolicy(RuntimeEvent.Initialize); if (policy != RuntimePolicy.Off) { CreateAndStartGlobalExecutionTimer(Configuration.FrameworkProvider.HttpRequestStore); var messageBroker = Configuration.MessageBroker; // TODO: Fix this to IDisplay no longer uses I*Tab*Setup var displaysThatRequireSetup = Configuration.Displays.Where(display => display is ITabSetup).Select(display => display); foreach (ITabSetup display in displaysThatRequireSetup) { var key = CreateKey(display); try { var setupContext = new TabSetupContext(logger, messageBroker, () => GetTabStore(key)); display.Setup(setupContext); } catch (Exception exception) { logger.Error(Resources.InitializeTabError, exception, key); } } var tabsThatRequireSetup = Configuration.Tabs.Where(tab => tab is ITabSetup).Select(tab => tab); foreach (ITabSetup tab in tabsThatRequireSetup) { var key = CreateKey(tab); try { var setupContext = new TabSetupContext(logger, messageBroker, () => GetTabStore(key)); tab.Setup(setupContext); } catch (Exception exception) { logger.Error(Resources.InitializeTabError, exception, key); } } var inspectorContext = new InspectorContext(logger, Configuration.ProxyFactory, messageBroker, Configuration.TimerStrategy, Configuration.RuntimePolicyStrategy); foreach (var inspector in Configuration.Inspectors) { try { inspector.Setup(inspectorContext); logger.Debug(Resources.GlimpseRuntimeInitializeSetupInspector, inspector.GetType()); } catch (Exception exception) { logger.Error(Resources.InitializeInspectorError, exception, inspector.GetType()); } } PersistMetadata(); } IsInitialized = true; } } } return policy != RuntimePolicy.Off; }