public void Refresh_EmptyCache_NoError()
        {
            var testSubject = new CachingAdornmentFactory(ValidTextView);

            Action act = () => testSubject.Refresh(new[] { ValidLocViz });

            act.Should().NotThrow();
        }
        public void Refresh_NoCurrentLocations_CacheCleared()
        {
            var testSubject = new CachingAdornmentFactory(ValidTextView);

            testSubject.CreateOrUpdate(CreateLocationViz());
            testSubject.CreateOrUpdate(CreateLocationViz());
            testSubject.CreateOrUpdate(CreateLocationViz());
            testSubject.CachedAdornments.Count.Should().Be(3); // sanity check

            testSubject.Refresh(Array.Empty <IAnalysisIssueLocationVisualization>());
            testSubject.CachedAdornments.Should().BeEmpty();
        }
        public void Refresh_NotAllCachedLocationsAreCurrent_ExpectedAdornmentsRemoved()
        {
            var testSubject = new CachingAdornmentFactory(ValidTextView);

            var locViz1 = CreateLocationViz();
            var locViz2 = CreateLocationViz();
            var locViz3 = CreateLocationViz();

            var adornment1 = testSubject.CreateOrUpdate(locViz1);
            var adornment2 = testSubject.CreateOrUpdate(locViz2);
            var adornment3 = testSubject.CreateOrUpdate(locViz3);

            testSubject.CachedAdornments.Should().BeEquivalentTo(new[] { adornment1, adornment2, adornment3 }); // sanity check

            // Remove multiple items
            testSubject.Refresh(new[] { locViz3 });
            testSubject.CachedAdornments.Should().BeEquivalentTo(new[] { adornment3 });

            // Remove the remaining item
            var newLocViz = CreateLocationViz();

            testSubject.Refresh(new[] { newLocViz });
            testSubject.CachedAdornments.Should().BeEmpty();
        }
        public void Refresh_AllCachedLocationsAreCurrent_NoAdormentsRemoved()
        {
            var testSubject = new CachingAdornmentFactory(ValidTextView);

            var locViz1        = CreateLocationViz();
            var locViz2        = CreateLocationViz();
            var uncachedLocViz = CreateLocationViz(); // new location that doesn't have an adornment yet

            var adornment1         = testSubject.CreateOrUpdate(locViz1);
            var adornment2         = testSubject.CreateOrUpdate(locViz2);
            var expectedAdornments = new[] { adornment1, adornment2 };

            // Act
            testSubject.Refresh(new[] { locViz1, locViz2, uncachedLocViz });
            testSubject.CachedAdornments.Should().BeEquivalentTo(expectedAdornments);
        }