Beispiel #1
0
        public void GetLocations_NoStores_EmptyList()
        {
            var testSubject = new IssueLocationStoreAggregator(Enumerable.Empty <IIssueLocationStore>());
            var result      = testSubject.GetLocations("test.cpp");

            result.Should().BeEmpty();
        }
Beispiel #2
0
        public void Contains_NoStores_False()
        {
            var testSubject = new IssueLocationStoreAggregator(Enumerable.Empty <IIssueLocationStore>());

            var result = testSubject.Contains(Mock.Of <IAnalysisIssueVisualization>());

            result.Should().BeFalse();
        }
Beispiel #3
0
        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");
        }
Beispiel #4
0
        public void Refresh_NoStores_NoException()
        {
            var testSubject = new IssueLocationStoreAggregator(Enumerable.Empty <IIssueLocationStore>());

            Action act = () => testSubject.Refresh(new [] { "test.cpp" });

            act.Should().NotThrow();
        }
Beispiel #5
0
        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");
        }
Beispiel #6
0
        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");
        }
Beispiel #7
0
        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();
        }
Beispiel #8
0
        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();
        }
Beispiel #9
0
        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);
            }
        }
Beispiel #10
0
        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();
        }
Beispiel #11
0
        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);
            }
        }
Beispiel #12
0
        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);
        }