public void ResultsDisposeCorrectlyAndOnce() { var dispose = 0; var cache = new CustomImageCacheStub(); var image = cache.Get(Colors.Red); var result = new ImageSourceServiceResult(image, () => dispose++); Assert.False(result.IsDisposed); Assert.Equal(0, dispose); result.Dispose(); Assert.True(result.IsDisposed); Assert.Equal(1, dispose); result.Dispose(); Assert.True(result.IsDisposed); Assert.Equal(1, dispose); cache.Return(Colors.Red); }
public async Task ResultsDisposeCorrectlyAndOnce() { var dispose = 0; var cache = new CustomImageCacheStub(); var image = await InvokeOnMainThreadAsync(() => cache.Get(Colors.Red)); var result = new ImageSourceServiceResult(image, () => dispose++); Assert.False(result.IsDisposed); Assert.Equal(0, dispose); result.Dispose(); Assert.True(result.IsDisposed); Assert.Equal(1, dispose); result.Dispose(); Assert.True(result.IsDisposed); Assert.Equal(1, dispose); cache.Return(Colors.Red); }