Skip to content

Commit

Permalink
SLVS-1721 Fix "Use shared configuration" button not shown after unbin…
Browse files Browse the repository at this point in the history
…d 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
  • Loading branch information
gabriela-trutan-sonarsource committed Dec 18, 2024
1 parent 6dffd27 commit 6b7e5a8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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<TaskToPerformParams<AdapterResponse>>(x =>
x.TaskToPerform == testSubject.CheckForSharedBindingAsync &&
Expand Down
10 changes: 4 additions & 6 deletions src/ConnectedMode/UI/ManageBinding/ManageBindingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,10 @@ public async Task InitializeDataAsync()
UiResources.FetchingBindingStatusFailedText) { AfterProgressUpdated = OnProgressUpdated };
await ProgressReporter.ExecuteTaskWithProgressAsync(displayBindStatus);

if (!IsCurrentProjectBound)
{
var detectSharedBinding = new TaskToPerformParams<AdapterResponse>(CheckForSharedBindingAsync, UiResources.CheckingForSharedBindingText,
UiResources.CheckingForSharedBindingFailedText) { AfterProgressUpdated = OnProgressUpdated };
await ProgressReporter.ExecuteTaskWithProgressAsync(detectSharedBinding);
}
var detectSharedBinding = new TaskToPerformParams<AdapterResponse>(CheckForSharedBindingAsync, UiResources.CheckingForSharedBindingText,
UiResources.CheckingForSharedBindingFailedText)
{ AfterProgressUpdated = OnProgressUpdated };
await ProgressReporter.ExecuteTaskWithProgressAsync(detectSharedBinding);
}

public async Task BindWithProgressAsync()
Expand Down

0 comments on commit 6b7e5a8

Please sign in to comment.