public async Task GetLeaderboardRepositoryHitCountTest() { // Arrange var hitCount = 0; _repositoryMock.GetLeaderboardFunc = () => { hitCount++; return(new LeaderboardContract()); }; // Act for (var i = 0; i < 5; i++) { await _cachedRepository.GetLeaderboard(5, 5, 5, 5); } // Verify that we hit the repository only once. Assert.AreEqual(1, hitCount); await Task.Delay(_memoryCacheService.ExpirationTimeSpan + TimeSpan.FromSeconds(1)); // Act for (var i = 0; i < 5; i++) { await _cachedRepository.GetLeaderboard(5, 5, 5, 5); } // Verify that we hit the repository twice. Assert.AreEqual(2, hitCount); }