Skip to content

Commit

Permalink
SLVS-1721 Fix "Use shared configuration" button not shown after unbind (
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriela-trutan-sonarsource authored and vnaskos-sonar committed Dec 18, 2024
1 parent e4ea6db commit e53e604
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 @@ -312,6 +312,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 @@ -564,13 +600,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 @@ -142,12 +142,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 e53e604

Please sign in to comment.