public void ActivateOk() { string settingsFileName = string.Format("{0}\\ServiceSettings.xml", m_TempPath); SettingsManager settingsManager = new SettingsManager(settingsFileName); settingsManager.ServiceGuid = s_TestServiceGuid; StackHashContextSettings settings = settingsManager.CreateNewContextSettings(); settings.ErrorIndexSettings.Folder = m_TempPath; settings.ErrorIndexSettings.Name = "TestIndex"; settings.ErrorIndexSettings.Type = ErrorIndexType.Xml; string licenseFileName = string.Format("{0}\\License.bin", m_TempPath); LicenseManager licenseManager = new LicenseManager(licenseFileName, s_TestServiceGuid); licenseManager.SetLicense(s_LicenseId); ScriptManager scriptManager = new ScriptManager(m_ScriptPath); IDebugger debugger = new Windbg(); ControllerContext context = new ControllerContext(settings, scriptManager, debugger, settingsManager, true, StackHashTestData.Default, licenseManager); Assert.AreEqual(false, context.IsActive); Assert.AreEqual(null, context.WinQualSyncTimerTask); // Hook up to receive admin events. context.AdminReports += new EventHandler <AdminReportEventArgs>(this.OnAdminReport); StackHashClientData clientData = new StackHashClientData(Guid.NewGuid(), "Mark", 24); context.Activate(clientData, false); // Wait for the activation event. m_ActivationAdminEvent.WaitOne(3000); Assert.AreEqual(1, m_AllReports.Count); Assert.AreEqual(clientData.ApplicationGuid, m_AllReports[0].Report.ClientData.ApplicationGuid); Assert.AreEqual(clientData.ClientId, m_AllReports[0].Report.ClientData.ClientId); Assert.AreEqual(clientData.ClientName, m_AllReports[0].Report.ClientData.ClientName); Assert.AreEqual(clientData.ClientRequestId, m_AllReports[0].Report.ClientData.ClientRequestId); Assert.AreEqual(0, m_AllReports[0].Report.ContextId); Assert.AreNotEqual(null, m_AllReports[0].Report.Description); Assert.AreNotEqual(null, m_AllReports[0].Report.Message); Assert.AreEqual(StackHashAdminOperation.ContextStateChanged, m_AllReports[0].Report.Operation); Assert.AreEqual(StackHashServiceErrorCode.NoError, m_AllReports[0].Report.ServiceErrorCode); Assert.AreEqual(null, m_AllReports[0].Report.LastException); Assert.AreEqual(null, m_AllReports[0].Report.LastException); Assert.AreEqual(StackHashAdminOperation.ContextStateChanged, m_AllReports[0].Report.Operation); StackHashContextStateAdminReport contextChanged = m_AllReports[0].Report as StackHashContextStateAdminReport; Assert.AreEqual(true, contextChanged.IsActivationAttempt); Assert.AreEqual(true, contextChanged.IsActive); Assert.AreEqual(true, context.IsActive); Assert.AreNotEqual(null, context.WinQualSyncTimerTask); context.Dispose(); }
/// <summary> /// Called by the contoller context objects to report an admin event /// </summary> /// <param name="sender">The task manager reporting the event.</param> /// <param name="e">The event arguments.</param> public void OnAdminReport(Object sender, EventArgs e) { AdminReportEventArgs args = e as AdminReportEventArgs; m_AllReports.Add(args); if (args.Report.Operation == StackHashAdminOperation.ContextStateChanged) { StackHashContextStateAdminReport contextChangedAdminReport = args.Report as StackHashContextStateAdminReport; if (contextChangedAdminReport.IsActivationAttempt) { m_ActivationAdminEvent.Set(); } else { m_DeactivationAdminEvent.Set(); } } }