From 6b7e5a87f8276dca12398651926b4e785f0ba77b Mon Sep 17 00:00:00 2001 From: Gabriela Trutan Date: Wed, 18 Dec 2024 11:47:00 +0100 Subject: [PATCH] SLVS-1721 Fix "Use shared configuration" button not shown after unbind by making sure that the SharedBindingConfigModel is initialized inside InitializeDataAsync even when project is bound. The problem was that, after unbinding the IsUseSharedBindingButtonVisible was returning false due to the fact that the SharedBindingConfigModel was null. If the property is filled instead should not make any difference in the logic of the dialog --- .../ManageBindingViewModelTests.cs | 40 ++++++++++++++++++- .../ManageBinding/ManageBindingViewModel.cs | 10 ++--- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/ConnectedMode.UnitTests/UI/ManageBinding/ManageBindingViewModelTests.cs b/src/ConnectedMode.UnitTests/UI/ManageBinding/ManageBindingViewModelTests.cs index 51fd618ad..af752c7f0 100644 --- a/src/ConnectedMode.UnitTests/UI/ManageBinding/ManageBindingViewModelTests.cs +++ b/src/ConnectedMode.UnitTests/UI/ManageBinding/ManageBindingViewModelTests.cs @@ -332,6 +332,42 @@ public void IsUseSharedBindingButtonEnabled_ReturnsTrueOnlyWhenNoBindingIsInProg testSubject.IsUseSharedBindingButtonEnabled.Should().Be(expectedResult); } + [TestMethod] + public void IsUseSharedBindingButtonVisible_SharedBindingConfigExistsAndProjectIsBound_ReturnsFalse() + { + testSubject.SharedBindingConfigModel = new SharedBindingConfigModel(); + testSubject.BoundProject = serverProject; + + testSubject.IsUseSharedBindingButtonVisible.Should().BeFalse(); + } + + [TestMethod] + public void IsUseSharedBindingButtonVisible_SharedBindingConfigExistsAndProjectIsUnbound_ReturnsTrue() + { + testSubject.SharedBindingConfigModel = new SharedBindingConfigModel(); + testSubject.BoundProject = null; + + testSubject.IsUseSharedBindingButtonVisible.Should().BeTrue(); + } + + [TestMethod] + public void IsUseSharedBindingButtonVisible_SharedBindingConfigDoesNotExistAndProjectIsBound_ReturnsFalse() + { + testSubject.SharedBindingConfigModel = null; + testSubject.BoundProject = serverProject; + + testSubject.IsUseSharedBindingButtonVisible.Should().BeFalse(); + } + + [TestMethod] + public void IsUseSharedBindingButtonVisible_SharedBindingConfigDoesNotExistAndProjectIsUnbound_ReturnsFalse() + { + testSubject.SharedBindingConfigModel = null; + testSubject.BoundProject = null; + + testSubject.IsUseSharedBindingButtonVisible.Should().BeFalse(); + } + [TestMethod] public void SharedBindingConfigModel_Set_RaisesEvents() { @@ -584,13 +620,13 @@ await progressReporterViewModel.Received(1) } [TestMethod] - public async Task InitializeDataAsync_WhenBound_DoesNotChecksForSharedBindingAndReportsProgress() + public async Task InitializeDataAsync_WhenBound_ChecksForSharedBindingAndReportsProgress() { testSubject.BoundProject = serverProject; await testSubject.InitializeDataAsync(); - await progressReporterViewModel.DidNotReceive() + await progressReporterViewModel.Received(1) .ExecuteTaskWithProgressAsync( Arg.Is>(x => x.TaskToPerform == testSubject.CheckForSharedBindingAsync && diff --git a/src/ConnectedMode/UI/ManageBinding/ManageBindingViewModel.cs b/src/ConnectedMode/UI/ManageBinding/ManageBindingViewModel.cs index 67eb8ca1b..9959dd653 100644 --- a/src/ConnectedMode/UI/ManageBinding/ManageBindingViewModel.cs +++ b/src/ConnectedMode/UI/ManageBinding/ManageBindingViewModel.cs @@ -141,12 +141,10 @@ public async Task InitializeDataAsync() UiResources.FetchingBindingStatusFailedText) { AfterProgressUpdated = OnProgressUpdated }; await ProgressReporter.ExecuteTaskWithProgressAsync(displayBindStatus); - if (!IsCurrentProjectBound) - { - var detectSharedBinding = new TaskToPerformParams(CheckForSharedBindingAsync, UiResources.CheckingForSharedBindingText, - UiResources.CheckingForSharedBindingFailedText) { AfterProgressUpdated = OnProgressUpdated }; - await ProgressReporter.ExecuteTaskWithProgressAsync(detectSharedBinding); - } + var detectSharedBinding = new TaskToPerformParams(CheckForSharedBindingAsync, UiResources.CheckingForSharedBindingText, + UiResources.CheckingForSharedBindingFailedText) + { AfterProgressUpdated = OnProgressUpdated }; + await ProgressReporter.ExecuteTaskWithProgressAsync(detectSharedBinding); } public async Task BindWithProgressAsync()