/// <summary> /// The event-handler that is invoked by the subscription that listens for updates /// on the <see cref="ISession"/> that is being represented by the view-model /// </summary> /// <param name="sessionChange"> /// The payload of the event that is being handled /// </param> protected virtual void SessionChangeEventHandler(SessionEvent sessionChange) { if (sessionChange.Status == SessionStatus.Open) { this.OpenSessions.Add( new RibbonMenuItemSessionFavoritesDependentViewModel(sessionChange.Session.Name, sessionChange.Session, this.InstantiatePanelViewModelFunction)); } else if (sessionChange.Status == SessionStatus.Closed) { this.RemoveOpenSession(sessionChange.Session); } }
public void VerifyThatAnyObjectCanServeAsAMessageAndBeReceived() { var mockedDal = new Mock <IDal>(); var credentials = new Credentials(" ", " ", this.uri); var session = new Session(mockedDal.Object, credentials); var sessionEvent = new SessionEvent(session, SessionStatus.Open); Assert.AreEqual(0, this.messagesReceivedCounter); CDPMessageBus.Current.Listen <SessionEvent>().Subscribe(x => this.MesssageReceived()); CDPMessageBus.Current.SendMessage(sessionEvent, null, null); Assert.AreEqual(1, this.messagesReceivedCounter); }
public void VerifyThatIfFluentRibbonIsNotActiveTheSessionEventHasNoEffect() { var fluentRibbonManager = new FluentRibbonManager(); fluentRibbonManager.IsActive = false; fluentRibbonManager.RegisterRibbonPart(this.ribbonPart); var sessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open); CDPMessageBus.Current.SendMessage(sessionEvent); Assert.IsNull(this.ribbonPart.Session); }
/// <summary> /// The event-handler that is invoked by the subscription that listens for updates /// on the <see cref="Session"/> that is being represented by the view-model /// </summary> /// <param name="sessionChange"> /// The payload of the event that is being handled /// </param> private void SessionChangeEventHandler(SessionEvent sessionChange) { if (sessionChange.Status == SessionStatus.Open) { this.OpenSessions.Add(sessionChange.Session); } else if (sessionChange.Status == SessionStatus.Closed) { this.OpenSessions.Remove(sessionChange.Session); } this.HasOpenSiteRdl = this.OpenSessions.SelectMany(x => x.OpenReferenceDataLibraries).Any(); }
public void SessionTimedOutEvent_MatchesReferenceJson() { var timedOutEvent = new SessionEvent(Action.TimedOut) { Actor = TestEntities.EpubViewerApp, Object = TestEntities.SessionEnd, EventTime = TestEntities.DefaultStartedAtTime, EdApp = TestEntities.EpubViewerApp, Group = TestEntities.AmRev101_Group001 }; JsonAssertions.AssertSameObjectJson(timedOutEvent, "caliperSessionTimeoutEvent"); }
/// <summary> /// The event-handler that is invoked by the subscription that listens for updates /// on the <see cref="Session"/> that is being represented by the view-model /// </summary> /// <param name="sessionChange"> /// The payload of the event that is being handled /// </param> private void SessionChangeEventHandler(SessionEvent sessionChange) { if (sessionChange.Status == SessionStatus.Open) { this.OpenSessions.Add(sessionChange.Session); } else if (sessionChange.Status == SessionStatus.Closed) { this.OpenSessions.Remove(sessionChange.Session); } this.HasOpenIterations = this.OpenSessions.SelectMany(x => x.OpenIterations).Any(); }
private void PressNes(InputEvent evt) { switch (evt.button) { case InputEvent.Buttons.Select: Session.Event(SessionEvent.PauseEvent()); break; case InputEvent.Buttons.B: actor.Jump(); break; case InputEvent.Buttons.A: actor.Use(Item.Uses.A); break; } }
public void VerifyThatSessionEventsAreCaught() { var vm = new HtmlExportRibbonViewModel(); var sessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open); CDPMessageBus.Current.SendMessage(sessionEvent); Assert.AreEqual(1, vm.Sessions.Count); sessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed); CDPMessageBus.Current.SendMessage(sessionEvent); Assert.AreEqual(0, vm.Sessions.Count); }
public void VerifyIfIterationIsAddedWhenMessageIsSent() { var viewmodel = new RuleVerificationListRibbonViewModel(); var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open); CDPMessageBus.Current.SendMessage(openSessionEvent); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Added); Assert.IsTrue(viewmodel.HasModels); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Removed); Assert.IsFalse(viewmodel.HasModels); }
public void VerifyThatIfFluentRibbonIsNotActiveTheSessionEventHasNoEffect() { this.ribbonPart = new RequirementRibbonPart(this.order, this.panelNavigationService.Object, this.negativeDialogNavigationService.Object, null, null, this.officeApplicationWrapper.Object); var fluentRibbonManager = new FluentRibbonManager(); fluentRibbonManager.IsActive = false; fluentRibbonManager.RegisterRibbonPart(this.ribbonPart); var sessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open); CDPMessageBus.Current.SendMessage(sessionEvent); Assert.IsNull(this.ribbonPart.Session); }
/// <summary> /// Close the underlying <see cref="IDal"/> and clears the encapsulated <see cref="Assembler"/> /// </summary> public async Task Close() { this.Dal.Close(); await this.Assembler.Clear(); var sessionChange = new SessionEvent(this, SessionStatus.Closed); CDPMessageBus.Current.SendMessage(sessionChange); logger.Info("Session {0} closed successfully", this.DataSourceUri); this.openReferenceDataLibraries.Clear(); this.ActivePerson = null; }
public void VerifyThatITerationEventAreCaught() { var vm = new HtmlExportRibbonViewModel(); var sessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open); CDPMessageBus.Current.SendMessage(sessionEvent); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Added); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Removed); Assert.AreEqual(0, vm.Iterations.Count); }
public async Task <RequestResult> SendSession(string serverUrl, SessionEvent sessionEvent, CountlyUserDetails userDetails = null) { string userDetailsJson = String.Empty; if (userDetails != null) { userDetailsJson = "&user_details=" + UtilityHelper.EncodeDataForURL(JsonConvert.SerializeObject(userDetails, Formatting.None, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore })); } return(await Call(serverUrl + sessionEvent.Content + userDetailsJson)); }
public void VerifyThatExportCommandIsExecuted() { var vm = new HtmlExportRibbonViewModel(); var sessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open); CDPMessageBus.Current.SendMessage(sessionEvent); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Added); vm.ExportCommand.Execute(null); this.dialogNavigationService.Verify(x => x.NavigateModal(It.IsAny <HtmlExportRequirementsSpecificationSelectionDialogViewModel>())); }
public void VerifyThatExportCommandIsEnabledAndDisabled() { var vm = new HtmlExportRibbonViewModel(); var sessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open); CDPMessageBus.Current.SendMessage(sessionEvent); Assert.IsFalse(vm.ExportCommand.CanExecute(null)); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Added); Assert.IsTrue(vm.ExportCommand.CanExecute(null)); }
public async Task VerifyThatOnActionPerformsExpectedResult() { await this.ribbonPart.OnAction("CDP4_Open"); this.dialogNavigationService.Verify(x => x.NavigateModal(It.IsAny <IDialogViewModel>())); var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open); CDPMessageBus.Current.SendMessage(openSessionEvent); await this.ribbonPart.OnAction("CDP4_Close"); this.session.Verify(x => x.Close()); }
public static async Task <ResultResponse> SendSession(string serverUrl, SessionEvent sesisonEvent, CountlyUserDetails userDetails = null) { string userDetailsJson = String.Empty; if (userDetails != null) { userDetailsJson = "&user_details=" + HttpUtility.UrlEncode(JsonConvert.SerializeObject(userDetails, Formatting.None, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore })); } return(await Call <ResultResponse>(serverUrl + sesisonEvent.Content + userDetailsJson)); }
public void SessionLoggedOutEvent_MatchesReferenceJson() { var loggedOutEvent = new SessionEvent(Action.LoggedOut) { Actor = TestEntities.User554433, Object = TestEntities.EpubViewerApp, Target = TestEntities.SessionEnd, EventTime = TestEntities.DefaultStartedAtTime, EdApp = TestEntities.EpubViewerApp, Group = TestEntities.AmRev101_Group001, Membership = TestEntities.User554433_AmRev101_CourseSection001_Membership }; JsonAssertions.AssertSameObjectJson(loggedOutEvent, "caliperSessionLogoutEvent"); }
public void VerifyThatWhenSessionIsOpenedAndClosedItIsAddedToAndRemovedFromSessionCollection() { var viewmodel = new RuleVerificationListRibbonViewModel(); Assert.IsEmpty(viewmodel.Sessions); var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open); CDPMessageBus.Current.SendMessage(openSessionEvent); Assert.IsNotEmpty(viewmodel.Sessions); var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed); CDPMessageBus.Current.SendMessage(closeSessionEvent); Assert.IsEmpty(viewmodel.Sessions); }
public void VerifyThatSessionChangeEventsAreProcessed() { Assert.IsEmpty(this.viewModel.Sessions); var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open); CDPMessageBus.Current.SendMessage(openSessionEvent); Assert.Contains(this.session.Object, this.viewModel.Sessions); var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed); CDPMessageBus.Current.SendMessage(closeSessionEvent); Assert.IsEmpty(this.viewModel.Sessions); }
/// <summary> /// The event-handler that is invoked by the subscription that listens for updates /// on the <see cref="Session"/> that is being represented by the view-model /// </summary> /// <param name="sessionChange"> /// The payload of the event that is being handled /// </param> private void SessionChangeEventHandler(SessionEvent sessionChange) { if (!this.IsVersionSupported(sessionChange.Session)) { return; } if (sessionChange.Status == SessionStatus.Open) { this.Sessions.Add(sessionChange.Session); } else if (sessionChange.Status == SessionStatus.Closed) { this.Sessions.Remove(sessionChange.Session); } }
/// <summary> /// Emit a specific event to all handlers /// </summary> /// <param name="sessionEvent">Event to emit</param> /// <param name="context">The current context</param> public void Emit(SessionEvent sessionEvent, TContext context) { if (_handlers != null) { foreach (var handler in _handlers) { try { handler.Handle(sessionEvent, context); } catch (Exception) { // TODO: Look at pulling handlers out of the set if they continually raise exceptions // this may not happen much though. } } } }
public void HandleItemDiscardedEvent(SessionEvent sessionEvent) { if (player.NodePath().ToString() != sessionEvent.args[0]) { return; } InventoryMenu invMenu = activeMenu as InventoryMenu; if (invMenu == null) { return; } invMenu.RefreshInventory(); }
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) { SystemEventArgs ea = new SystemEventArgs(); switch (e.Mode) { case PowerModes.Resume: ea.newState = State.Resume; break; case PowerModes.Suspend: ea.newState = State.Suspend; break; } SessionEvent.RaiseMarshalled(this, ea); }
/// <summary> /// The event-handler that is invoked by the subscription that listens for updates /// on the <see cref="Session"/> that is being represented by the view-model /// </summary> /// <param name="sessionChange"> /// The payload of the event that is being handled /// </param> private void SessionChangeEventHandler(SessionEvent sessionChange) { if (sessionChange.Status == SessionStatus.Open) { this.Sessions.Add(sessionChange.Session); } else if (sessionChange.Status == SessionStatus.Closed) { this.Sessions.Remove(sessionChange.Session); var iterationsToRemove = this.Iterations.Where(x => x.Cache == sessionChange.Session.Assembler.Cache); foreach (var iterationToRemove in iterationsToRemove) { this.Iterations.Remove(iterationToRemove); } } }
public void Update() { lock (_sync_obj) { while (0 < _event_queue.Count) { SessionEvent evt = _event_queue[0]; _event_queue.RemoveAt(0); evt.Event(); } } if (Application.internetReachability != _networkReachability) { _networkReachability = Application.internetReachability; Close(); } }
public void HandleEvent(SessionEvent sessionEvent) { if (Session.NetActive() && sessionEvent.type == SessionEvent.Types.ItemDiscarded) { HandleItemDiscardedEvent(sessionEvent); // Refresh inventory when deferred discard item. } if (arena != null) { arena.HandleEvent(sessionEvent); } if (adventure != null) { adventure.HandleEvent(sessionEvent); } }
public void VerifyThatOnActionInvokesTheNavigationServiceOpenAndCloseMethod() { var fluentRibbonManager = new FluentRibbonManager(); fluentRibbonManager.IsActive = true; fluentRibbonManager.RegisterRibbonPart(this.ribbonPart); // open viemodels var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open); CDPMessageBus.Current.SendMessage(openSessionEvent); this.ribbonPart.OnAction("ShowDomainsOfExpertise"); this.panelNavigationService.Verify(x => x.Open(It.IsAny <DomainOfExpertiseBrowserViewModel>(), false)); this.ribbonPart.OnAction("ShowModels"); this.panelNavigationService.Verify(x => x.Open(It.IsAny <ModelBrowserViewModel>(), false)); this.ribbonPart.OnAction("ShowLanguages"); this.panelNavigationService.Verify(x => x.Open(It.IsAny <NaturalLanguageBrowserViewModel>(), false)); this.ribbonPart.OnAction("ShowOrganizations"); this.panelNavigationService.Verify(x => x.Open(It.IsAny <OrganizationBrowserViewModel>(), false)); this.ribbonPart.OnAction("ShowRoles"); this.panelNavigationService.Verify(x => x.Open(It.IsAny <RoleBrowserViewModel>(), false)); this.ribbonPart.OnAction("ShowPersons"); this.panelNavigationService.Verify(x => x.Open(It.IsAny <PersonBrowserViewModel>(), false)); this.ribbonPart.OnAction("ShowSiteRDLs"); this.panelNavigationService.Verify(x => x.Open(It.IsAny <SiteRdlBrowserViewModel>(), false)); // close viewmodels var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed); CDPMessageBus.Current.SendMessage(closeSessionEvent); this.panelNavigationService.Verify(x => x.Close(It.IsAny <DomainOfExpertiseBrowserViewModel>(), false)); this.panelNavigationService.Verify(x => x.Close(It.IsAny <ModelBrowserViewModel>(), false)); this.panelNavigationService.Verify(x => x.Close(It.IsAny <NaturalLanguageBrowserViewModel>(), false)); this.panelNavigationService.Verify(x => x.Close(It.IsAny <OrganizationBrowserViewModel>(), false)); this.panelNavigationService.Verify(x => x.Close(It.IsAny <RoleBrowserViewModel>(), false)); this.panelNavigationService.Verify(x => x.Close(It.IsAny <PersonBrowserViewModel>(), false)); this.panelNavigationService.Verify(x => x.Close(It.IsAny <SiteRdlBrowserViewModel>(), false)); }
/// <summary> /// The event-handler that is invoked by the subscription that listens for updates /// on the <see cref="Session"/> that is being represented by the view-model /// </summary> /// <param name="sessionChange"> /// The payload of the event that is being handled /// </param> private void SessionChangeEventHandler(SessionEvent sessionChange) { if (!this.FluentRibbonManager.IsActive) { return; } if (sessionChange.Status == SessionStatus.Open) { this.session = sessionChange.Session; } if (sessionChange.Status == SessionStatus.Closed) { this.session = null; } }
/// <summary> /// The event-handler that is invoked by the subscription that listens for updates /// on the <see cref="Session"/> that is being represented by the view-model /// </summary> /// <param name="sessionChange"> /// The payload of the event that is being handled /// </param> private void SessionChangeEventHandler(SessionEvent sessionChange) { switch (sessionChange.Status) { case SessionStatus.Open: this.Sessions.Add(sessionChange.Session); break; case SessionStatus.Closed: this.Sessions.Remove(sessionChange.Session); break; default: // do nothing break; } }