-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SLVS-1406 Add binding changed trigger to ActiveSolutionBoundTracker #5642
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,7 +218,7 @@ public void ActiveSolutionBoundTracker_Changes() | |
ConfigureSolutionBinding(null); | ||
|
||
// Act | ||
host.VisualStateManager.ClearBoundProject(); | ||
testSubject.HandleBindingChange(true); | ||
|
||
// Assert | ||
testSubject.CurrentConfiguration.Mode.Should().Be(SonarLintMode.Standalone, "Unbound solution should report false activation"); | ||
|
@@ -235,7 +235,7 @@ public void ActiveSolutionBoundTracker_Changes() | |
// Case 2: Set bound project | ||
ConfigureSolutionBinding(boundProject); | ||
// Act | ||
host.VisualStateManager.SetBoundProject(new Uri("http://localhost"), null, "project123"); | ||
testSubject.HandleBindingChange(false); | ||
|
||
// Assert | ||
testSubject.CurrentConfiguration.Mode.Should().Be(SonarLintMode.Connected, "Bound solution should report true activation"); | ||
|
@@ -307,7 +307,7 @@ public void ActiveSolutionBoundTracker_Changes() | |
// Act | ||
testSubject.Dispose(); | ||
ConfigureSolutionBinding(boundProject); | ||
host.VisualStateManager.ClearBoundProject(); | ||
testSubject.HandleBindingChange(true); | ||
|
||
// Assert | ||
eventCounter.PreSolutionBindingChangedCount.Should().Be(5, "Once disposed should stop raising the event"); | ||
|
@@ -349,8 +349,48 @@ public void OnBindingStateChanged_NewConfiguration_EventsRaisedInCorrectOrder() | |
// Assert | ||
// Different config so event should be raised | ||
eventCounter.PreSolutionBindingChangedCount.Should().Be(1); | ||
eventCounter.PreSolutionBindingUpdatedCount.Should().Be(0); | ||
eventCounter.SolutionBindingChangedCount.Should().Be(1); | ||
eventCounter.SolutionBindingUpdatedCount.Should().Be(0); | ||
|
||
eventCounter.RaisedEventNames.Should().HaveCount(2); | ||
eventCounter.RaisedEventNames[0].Should().Be("PreSolutionBindingChanged"); | ||
eventCounter.RaisedEventNames[1].Should().Be("SolutionBindingChanged"); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void HandleBindingChange_NewConfiguration_EventsRaisedInCorrectOrder() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test seems to be a copy-past of OnBindingStateChanged_NewConfiguration_EventsRaisedInCorrectOrder. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The event-based test will be removed once we get rid of the old binding window |
||
{ | ||
// Arrange | ||
var initialProject = new BoundServerProject( | ||
"solution", | ||
"projectKey", | ||
new ServerConnection.SonarCloud("myOrgKey")); | ||
|
||
// Set the current configuration used by the tracker | ||
ConfigureSolutionBinding(initialProject); | ||
using (var testSubject = CreateTestSubject(this.host, this.activeSolutionTracker, this.configProvider, loggerMock.Object)) | ||
{ | ||
var eventCounter = new EventCounter(testSubject); | ||
|
||
// Now configure the provider to return a different configuration | ||
var newProject = new BoundServerProject( | ||
"solution", | ||
"projectKey", | ||
new ServerConnection.SonarCloud("myOrgKey_DIFFERENT")); | ||
ConfigureSolutionBinding(newProject); | ||
|
||
// Act - simulate the binding state changing in the Team explorer section. | ||
// The project configuration hasn't changed (it doesn't matter what properties | ||
// we pass here; they aren't used when raising the event.) | ||
testSubject.HandleBindingChange(false); | ||
|
||
// Assert | ||
// Different config so event should be raised | ||
eventCounter.PreSolutionBindingChangedCount.Should().Be(1); | ||
eventCounter.PreSolutionBindingUpdatedCount.Should().Be(0); | ||
eventCounter.SolutionBindingChangedCount.Should().Be(1); | ||
eventCounter.SolutionBindingUpdatedCount.Should().Be(0); | ||
|
||
eventCounter.RaisedEventNames.Should().HaveCount(2); | ||
|
@@ -521,6 +561,25 @@ public void SolutionBindingUpdated_WhenClearBoundProject_NotRaised() | |
eventCounter.SolutionBindingChangedCount.Should().Be(0); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void HandleBindingChange_WhenClearBoundProject_NotRaised() | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test seems to be a copy-past of SolutionBindingUpdated_WhenClearBoundProject_NotRaised. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The event-based test will be removed once we get rid of the old binding window |
||
// Arrange | ||
using (var testSubject = CreateTestSubject(this.host, this.activeSolutionTracker, this.configProvider, loggerMock.Object)) | ||
{ | ||
var eventCounter = new EventCounter(testSubject); | ||
|
||
// Act | ||
testSubject.HandleBindingChange(true); | ||
|
||
// Assert | ||
eventCounter.PreSolutionBindingUpdatedCount.Should().Be(0); | ||
eventCounter.SolutionBindingUpdatedCount.Should().Be(0); | ||
eventCounter.PreSolutionBindingChangedCount.Should().Be(0); | ||
eventCounter.SolutionBindingChangedCount.Should().Be(0); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void SolutionBindingUpdated_WhenSetBoundProject_EventsRaisedInExpectedOrder() | ||
|
@@ -544,6 +603,29 @@ public void SolutionBindingUpdated_WhenSetBoundProject_EventsRaisedInExpectedOrd | |
eventCounter.RaisedEventNames[1].Should().Be("SolutionBindingUpdated"); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void HandleBindingChange_WhenSetBoundProject_EventsRaisedInExpectedOrder() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test seems to be a copy-past of SolutionBindingUpdated_WhenSetBoundProject_EventsRaisedInExpectedOrder. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The event-based test will be removed once we get rid of the old binding window |
||
{ | ||
// Arrange | ||
using (var testSubject = CreateTestSubject(this.host, this.activeSolutionTracker, this.configProvider, loggerMock.Object)) | ||
{ | ||
var eventCounter = new EventCounter(testSubject); | ||
|
||
// Act | ||
testSubject.HandleBindingChange(false); | ||
|
||
// Assert | ||
eventCounter.PreSolutionBindingUpdatedCount.Should().Be(1); | ||
eventCounter.SolutionBindingUpdatedCount.Should().Be(1); | ||
eventCounter.PreSolutionBindingChangedCount.Should().Be(0); | ||
eventCounter.SolutionBindingChangedCount.Should().Be(0); | ||
|
||
eventCounter.RaisedEventNames.Should().HaveCount(2); | ||
eventCounter.RaisedEventNames[0].Should().Be("PreSolutionBindingUpdated"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use name of instead of hardcoded string for event name. |
||
eventCounter.RaisedEventNames[1].Should().Be("SolutionBindingUpdated"); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void GitRepoUpdated_SolutionBindingUpdatedEventsRaised() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use name of instead of hardcoded string for event name.
Maybe search and replace in the whole file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't change these, but I can try to fix this.