public void Cache_CanDispose_WhenUninitialized() { // Arrange var count = 0; var dataSource = new DynamicEndpointDataSource(); var cache = new DataSourceDependentCache <string>(dataSource, (endpoints) => { count++; return($"hello, {count}!"); }); // Act cache.Dispose(); // Assert dataSource.AddEndpoint(null); Assert.Null(cache.Value); }
public void Cache_CanDispose_WhenInitialized() { // Arrange var count = 0; var dataSource = new DynamicEndpointDataSource(); var cache = new DataSourceDependentCache <string>(dataSource, (endpoints) => { count++; return($"hello, {count}!"); }); cache.EnsureInitialized(); Assert.Equal("hello, 1!", cache.Value); // Act cache.Dispose(); // Assert dataSource.AddEndpoint(null); Assert.Equal("hello, 1!", cache.Value); // Ignores update }
public void Dispose() { _cache.Dispose(); }