public async Task GetItems_when_non_existant_returns_default() { _fileMock.Setup(file => file.Exists) .Returns(false) .Verifiable(); _fileServiceMock.Setup(fileService => fileService.GetFile(It.IsAny <string>())) .Returns(_fileMock.Object) .Verifiable(); var result = await _sut.GetItems(CancellationToken.None); Assert.IsNull(result); _fileMock.Verify(); _fileServiceMock.Verify(); }
private async Task <IDictionary <string, CacheEntryState> > GetOrSetItems(bool commitChanges, CancellationToken cancellationToken) { var items = await _cacheTrackerStore.GetItems(cancellationToken); if (items == null) { _log.LogInformation("State information currently unavailable, creating new..."); } if (items == null && commitChanges) { await _cacheTrackerStore.SaveItems(items = new Dictionary <string, CacheEntryState>(), cancellationToken); } return(items ?? new Dictionary <string, CacheEntryState>()); }