public void CreateNew_Benchmark() { // Arrange var subject = new GuidFactory(); var timer = Stopwatch.StartNew(); for (var i = 0; i < TestIterations; i++) { // Act subject.CreateNew(); } // Assert timer.Stop(); timer.ElapsedMilliseconds.Should().BeLessOrEqualTo(400); }
public void CreateNew_ShouldReturnNewGuid_WithoutCollisions() { // Arrange var uniqueResults = new HashSet <Guid>(); var subject = new GuidFactory(); for (var i = 0; i < TestIterations; i++) { // Act var result = subject.CreateNew(); // Assert uniqueResults.Add(result).Should().BeTrue(); } uniqueResults.Should().HaveCount(TestIterations); uniqueResults.Should().NotContain(Guid.Empty); }
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); }