Created
January 29, 2021 09:43
-
-
Save VisualBean/24da79cdbca4c35a1d4d8aa7a0b21312 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public async Task Collapser_WithMultipleExecutions_OnlyRunsOnce() | |
{ | |
int i = 0; | |
var collapser = new Collapser<int>(TimeSpan.FromMilliseconds(100)); | |
Func<CancellationToken, Task<int>> action = (ct) => { i++; return Task.FromResult(i); }; | |
await collapser.ExecuteAsync(action, default); | |
await collapser.ExecuteAsync(action, default); | |
await collapser.ExecuteAsync(action, default); | |
var result = await collapser.ExecuteAsync(action, default); | |
i.Should().Be(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment