Skip to content

Commit

Permalink
Better assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
soenneker committed Dec 1, 2024
1 parent 005b8e0 commit 6474452
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using Soenneker.Utils.AutoBogus.Tests.Dtos.Simple;
using Xunit;

Expand All @@ -26,10 +27,10 @@ public void Generate_with_ParallelExecution()
});

// Assert
Assert.Equal(numberOfTasks, results.Count);
results.Count.Should().Be(numberOfTasks);

List<int> ids = results.Select(x => x.Id).ToList();
Assert.Equal(ids.Count, ids.Distinct().Count()); // Ensure IDs are unique
ids.Should().OnlyHaveUniqueItems();
}

[Fact]
Expand All @@ -48,9 +49,9 @@ public async Task Generate_with_ParallelExecutionTasks()
TestClassWithSimpleProperties[] results = await Task.WhenAll(tasks);

// Assert
Assert.Equal(numberOfTasks, results.Length);
results.Length.Should().Be(numberOfTasks);

List<int> ids = results.Select(x => x.Id).ToList();
Assert.Equal(ids.Count, ids.Distinct().Count()); // Ensure IDs are unique
ids.Should().OnlyHaveUniqueItems();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PackageReference Include="Ardalis.SmartEnum.JsonNet" Version="8.1.0" />
<PackageReference Include="Ardalis.SmartEnum.SystemTextJson" Version="8.1.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="FluentAssertions" Version="6.12.2" />
<PackageReference Include="FluentAssertions" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Soenneker.Facts.Local" Version="3.0.331" />
<PackageReference Include="Soenneker.Facts.Manual" Version="3.0.119" />
Expand Down

0 comments on commit 6474452

Please sign in to comment.