public async Task CreateNewAsync_Benchmark() { // Arrange var tasks = new Task <Guid> [TestIterations]; var subject = new GuidFactory(); var timer = Stopwatch.StartNew(); for (var i = 0; i < TestIterations; i++) { // Act tasks[i] = subject.CreateNewAsync(); } // Assert await Task.WhenAll(tasks).ConfigureAwait(false); // Assert timer.Stop(); timer.ElapsedMilliseconds.Should().BeLessOrEqualTo(400); }
public async Task CreateNewAsync_ShouldReturnNewGuid_WithoutCollisions() { // Arrange var tasks = new Task <Guid> [TestIterations]; var subject = new GuidFactory(); for (var i = 0; i < TestIterations; i++) { // Act tasks[i] = subject.CreateNewAsync(); } // Assert var results = await Task.WhenAll(tasks).ConfigureAwait(false); var uniqueResults = new HashSet <Guid>(results); uniqueResults.Should().HaveCount(TestIterations); uniqueResults.Should().NotContain(Guid.Empty); }