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_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); }
public void CreateOrUpdate_Exists_ReturnsExistingAdornment() { var testSubject = new CachingAdornmentFactory(ValidTextView); var locViz1 = CreateLocationViz(); var locViz2 = CreateLocationViz(); // Populate the cache var adornment1 = testSubject.CreateOrUpdate(locViz1); var adornment2 = testSubject.CreateOrUpdate(locViz2); testSubject.CachedAdornments.Should().BeEquivalentTo(adornment1, adornment2); // Act testSubject.CreateOrUpdate(locViz1).Should().Be(adornment1); testSubject.CreateOrUpdate(locViz2).Should().Be(adornment2); testSubject.CachedAdornments.Should().BeEquivalentTo(adornment1, adornment2); }
public void CreateOrUpdate_DoesNotExist_ReturnsNewAdornment() { var testSubject = new CachingAdornmentFactory(ValidTextView); var newLocViz1 = CreateLocationViz(); var newLocViz2 = CreateLocationViz(); // Create an adornment var actual1 = testSubject.CreateOrUpdate(newLocViz1); actual1.LocationViz.Should().Be(newLocViz1); testSubject.CachedAdornments.Should().BeEquivalentTo(actual1); // Create another adornment var actual2 = testSubject.CreateOrUpdate(newLocViz2); actual2.LocationViz.Should().Be(newLocViz2); actual1.Should().NotBe(actual2); testSubject.CachedAdornments.Should().BeEquivalentTo(actual1, actual2); }
public void CreateOrUpdate_Exists_AdornmentIsUpdated() { var lineSource1 = CreateFormattedLineSource(12d); var lineSource2 = CreateFormattedLineSource(18d); var textView = CreateWpfTextView(ValidSnapshot, lineSource1); var testSubject = new CachingAdornmentFactory(textView); var locViz = CreateLocationViz(); var actual1 = testSubject.CreateOrUpdate(locViz); (actual1.Child as TextBlock).FontSize.Should().Be(10d); // sanity check ChangedMockedLineSource(textView, lineSource2); // Act var actual2 = testSubject.CreateOrUpdate(locViz); (actual2.Child as TextBlock).FontSize.Should().Be(16d); }
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(); }