diff --git a/COMET.Web.Common/ViewModels/Components/Applications/ApplicationBaseViewModel.cs b/COMET.Web.Common/ViewModels/Components/Applications/ApplicationBaseViewModel.cs index 2929e485..a2250c8b 100644 --- a/COMET.Web.Common/ViewModels/Components/Applications/ApplicationBaseViewModel.cs +++ b/COMET.Web.Common/ViewModels/Components/Applications/ApplicationBaseViewModel.cs @@ -2,7 +2,7 @@ // // Copyright (c) 2023 RHEA System S.A. // -// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, Miguel Serra // // This file is part of COMET WEB Community Edition // The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 @@ -53,7 +53,7 @@ public abstract class ApplicationBaseViewModel : HaveObjectChangedTracking, IApp protected ApplicationBaseViewModel(ISessionService sessionService) { this.Disposables.Add(CDPMessageBus.Current.Listen() - .Where(x => x.Status == SessionStatus.EndUpdate) + .Where(x => x.Session == this.SessionService?.Session && x.Status == SessionStatus.EndUpdate) .SubscribeAsync(_ => this.OnSessionRefreshed())); this.SessionService = sessionService; diff --git a/COMETwebapp.Tests/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModelTestFixture.cs b/COMETwebapp.Tests/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModelTestFixture.cs index ce7c4d2a..d815dbbe 100644 --- a/COMETwebapp.Tests/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModelTestFixture.cs +++ b/COMETwebapp.Tests/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModelTestFixture.cs @@ -2,7 +2,7 @@ // // Copyright (c) 2023 RHEA System S.A. // -// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, Miguel Serra // // This file is part of COMET WEB Community Edition // The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. @@ -56,6 +56,7 @@ public class ParameterEditorBodyViewModelTestFixture private IParameterEditorBodyViewModel viewModel; private Mock tableViewModel; private Iteration iteration; + private Mock session; [SetUp] public void SetUp() @@ -209,11 +210,11 @@ public void SetUp() this.iteration.DefaultOption = this.iteration.Option.First(); var sessionService = new Mock(); - var session = new Mock(); + this.session = new Mock(); var permissionService = new Mock(); permissionService.Setup(x => x.CanWrite(It.IsAny())).Returns(true); - session.Setup(x => x.PermissionService).Returns(permissionService.Object); - sessionService.Setup(x => x.Session).Returns(session.Object); + this.session.Setup(x => x.PermissionService).Returns(permissionService.Object); + sessionService.Setup(x => x.Session).Returns(this.session.Object); sessionService.Setup(x => x.GetDomainOfExpertise(this.iteration)).Returns(domain); var subscriptionService = new Mock(); @@ -281,7 +282,7 @@ public async Task VerifyApplyFilters() [Test] public async Task VerifyRefresh() { - CDPMessageBus.Current.SendMessage(new SessionEvent(null, SessionStatus.EndUpdate)); + CDPMessageBus.Current.SendMessage(new SessionEvent(this.session.Object, SessionStatus.EndUpdate)); Assert.Multiple(() => { @@ -297,19 +298,19 @@ public async Task VerifyRefresh() this.iteration.Element.Add(elementDefinition); CDPMessageBus.Current.SendObjectChangeEvent(elementDefinition, EventKind.Added); - CDPMessageBus.Current.SendMessage(new SessionEvent(null, SessionStatus.EndUpdate)); + CDPMessageBus.Current.SendMessage(new SessionEvent(this.session.Object, SessionStatus.EndUpdate)); await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading); this.tableViewModel.Verify(x => x.AddRows(It.Is>(c => c.Any())), Times.Once); CDPMessageBus.Current.SendObjectChangeEvent(elementDefinition, EventKind.Updated); - CDPMessageBus.Current.SendMessage(new SessionEvent(null, SessionStatus.EndUpdate)); + CDPMessageBus.Current.SendMessage(new SessionEvent(this.session.Object, SessionStatus.EndUpdate)); await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading); this.tableViewModel.Verify(x => x.UpdateRows(It.Is>(c => c.Any())), Times.Once); CDPMessageBus.Current.SendObjectChangeEvent(elementDefinition, EventKind.Removed); - CDPMessageBus.Current.SendMessage(new SessionEvent(null, SessionStatus.EndUpdate)); + CDPMessageBus.Current.SendMessage(new SessionEvent(this.session.Object, SessionStatus.EndUpdate)); await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading); this.tableViewModel.Verify(x => x.RemoveRows(It.Is>(c => c.Any())), Times.Once); @@ -319,7 +320,7 @@ public async Task VerifyRefresh() Container = new Iteration() }, EventKind.Removed); - CDPMessageBus.Current.SendMessage(new SessionEvent(null, SessionStatus.EndUpdate)); + CDPMessageBus.Current.SendMessage(new SessionEvent(this.session.Object, SessionStatus.EndUpdate)); await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading); this.tableViewModel.Verify(x => x.RemoveRows(It.Is>(c => c.Any())), Times.Once);