public async Task NotDisposePreviousData_When_FirstLoad() { // Arrange var methodCount = 0; Action <object> mockAction = data => methodCount++; var sut = new OnDataLostDataLoaderStrategy(mockAction); sut.InnerStrategy = new MockDelegatingDataLoaderStrategy(() => Task.FromResult(new object())); // Act await sut.Load(CancellationToken.None, null); // Assert methodCount.Should().Be(0); }
public async Task DisposePreviousData_If_LoadReturnsNewReference(object firstLoad, object secondLoad, int expectedMethodCount) { // Arrange var methodCount = 0; var isFirstLoad = true; Action <object> mockAction = data => methodCount++; var sut = new OnDataLostDataLoaderStrategy(mockAction); sut.InnerStrategy = new MockDelegatingDataLoaderStrategy(() => { var result = isFirstLoad ? firstLoad : secondLoad; return(Task.FromResult(result)); }); await sut.Load(CancellationToken.None, null); isFirstLoad = false; // Act await sut.Load(CancellationToken.None, null); // Assert methodCount.Should().Be(expectedMethodCount); }