public void GetLocations_NoStores_EmptyList() { var testSubject = new IssueLocationStoreAggregator(Enumerable.Empty <IIssueLocationStore>()); var result = testSubject.GetLocations("test.cpp"); result.Should().BeEmpty(); }
public void Contains_NoStores_False() { var testSubject = new IssueLocationStoreAggregator(Enumerable.Empty <IIssueLocationStore>()); var result = testSubject.Contains(Mock.Of <IAnalysisIssueVisualization>()); result.Should().BeFalse(); }
public void Contains_IssueVizIsNull_ArgumentNullException() { var testSubject = new IssueLocationStoreAggregator(Enumerable.Empty <IIssueLocationStore>()); Action act = () => testSubject.Contains(null); act.Should().Throw <ArgumentNullException>().And.ParamName.Should().Be("issueVisualization"); }
public void Refresh_NoStores_NoException() { var testSubject = new IssueLocationStoreAggregator(Enumerable.Empty <IIssueLocationStore>()); Action act = () => testSubject.Refresh(new [] { "test.cpp" }); act.Should().NotThrow(); }
public void Refresh_NullFilePaths_ArgumentNullException() { var testSubject = new IssueLocationStoreAggregator(Enumerable.Empty <IIssueLocationStore>()); Action act = () => testSubject.Refresh(null); act.Should().Throw <ArgumentNullException>().And.ParamName.Should().Be("affectedFilePaths"); }
public void GetLocations_NullPath_ArgumentNullException() { var testSubject = new IssueLocationStoreAggregator(Enumerable.Empty <IIssueLocationStore>()); Action act = () => testSubject.GetLocations(null); act.Should().Throw <ArgumentNullException>().And.ParamName.Should().Be("filePath"); }
public void IssuesChanged_Unsubscribe_NoStores_NoException() { var eventHandler = new Mock <EventHandler <IssuesChangedEventArgs> >(); var testSubject = new IssueLocationStoreAggregator(Enumerable.Empty <IIssueLocationStore>()); Action act = () => testSubject.IssuesChanged -= eventHandler.Object; act.Should().NotThrow(); }
public void Contains_HasStores_IssueExists_True() { var issueViz = Mock.Of <IAnalysisIssueVisualization>(); var store1 = new Mock <IIssueLocationStore>(); store1.Setup(x => x.Contains(issueViz)).Returns(false); var store2 = new Mock <IIssueLocationStore>(); store2.Setup(x => x.Contains(issueViz)).Returns(true); var stores = new[] { store1.Object, store2.Object }; var testSubject = new IssueLocationStoreAggregator(stores); var result = testSubject.Contains(issueViz); result.Should().BeTrue(); }
public void Refresh_HasStores_AllStoresRefreshed() { var stores = new List <Mock <IIssueLocationStore> > { new Mock <IIssueLocationStore>(), new Mock <IIssueLocationStore>(), new Mock <IIssueLocationStore>() }; var affectedFilePaths = new[] { "a.cpp", "b.cpp" }; var testSubject = new IssueLocationStoreAggregator(stores.Select(x => x.Object)); testSubject.Refresh(affectedFilePaths); foreach (var store in stores) { store.Verify(x => x.Refresh(affectedFilePaths), Times.Once); } }
public void GetLocations_NoMatchingLocations_EmptyList() { const string filePath = "test.cpp"; var stores = new List <Mock <IIssueLocationStore> > { new Mock <IIssueLocationStore>(), new Mock <IIssueLocationStore>(), new Mock <IIssueLocationStore>() }; foreach (var store in stores) { store .Setup(x => x.GetLocations(filePath)) .Returns(Enumerable.Empty <IAnalysisIssueLocationVisualization>()); } var testSubject = new IssueLocationStoreAggregator(Enumerable.Empty <IIssueLocationStore>()); var result = testSubject.GetLocations(filePath); result.Should().BeEmpty(); }
public void IssuesChanged_Subscribe_SubscribesToAllStores() { var stores = new List <Mock <IIssueLocationStore> > { new Mock <IIssueLocationStore>(), new Mock <IIssueLocationStore>(), new Mock <IIssueLocationStore>() }; foreach (var store in stores) { store.SetupAdd(x => x.IssuesChanged += (sender, args) => { }); } var eventHandler = new Mock <EventHandler <IssuesChangedEventArgs> >(); var testSubject = new IssueLocationStoreAggregator(stores.Select(x => x.Object)); testSubject.IssuesChanged += eventHandler.Object; foreach (var store in stores) { store.VerifyAdd(x => x.IssuesChanged += eventHandler.Object, Times.Once); } }
public void GetLocations_HasMatchingLocations_LocationsReturned() { const string filePath = "test.cpp"; var store1 = new Mock <IIssueLocationStore>(); store1.Setup(x => x.GetLocations(filePath)).Returns(Enumerable.Empty <IAnalysisIssueLocationVisualization>()); var location1 = Mock.Of <IAnalysisIssueLocationVisualization>(); var store2 = new Mock <IIssueLocationStore>(); store2.Setup(x => x.GetLocations(filePath)).Returns(new [] { location1 }); var location2 = Mock.Of <IAnalysisIssueLocationVisualization>(); var location3 = Mock.Of <IAnalysisIssueLocationVisualization>(); var store3 = new Mock <IIssueLocationStore>(); store3.Setup(x => x.GetLocations(filePath)).Returns(new[] { location2, location3 }); var testSubject = new IssueLocationStoreAggregator(new[] { store1.Object, store2.Object, store3.Object }); var result = testSubject.GetLocations(filePath); result.Should().BeEquivalentTo(location1, location2, location3); }