Exemple #1
0
    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);
    }
Exemple #2
0
    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
    }
Exemple #3
0
 public void Dispose()
 {
     _cache.Dispose();
 }