Skip to content

Instantly share code, notes, and snippets.

@samueleresca
Last active April 3, 2020 18:04
Show Gist options
  • Save samueleresca/348970b6c6ebfdbc8150d6ba58fb08ba to your computer and use it in GitHub Desktop.
Save samueleresca/348970b6c6ebfdbc8150d6ba58fb08ba to your computer and use it in GitHub Desktop.
[Fact]
public async Task multiple_threads_should_get_data_correctly()
{
LRUCache<int> cache = new LRUCache<int>(3);
Task[] tasks = new[] {
Task.Run(() => cache.Set(1, 3)),
Task.Run(() => cache.Set(1, 3)),
Task.Run(() => cache.Set(1, 3))
};
await Task.WhenAll(tasks);
Assert.NotNull(cache.Get(1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment