Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add final reproduction test and clean up test files
Co-authored-by: thomhurst <[email protected]>
  • Loading branch information
Copilot and thomhurst committed Aug 16, 2025
commit 092ec1e28c2bde27f8c6240bdedd77ddb83fcbbf
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

namespace TUnit.TestProject;

// This is the EXACT reproduction case from the GitHub issue
public sealed class Dependency
{
private static int _value = 0;
public int Value { get; } = Interlocked.Increment(ref _value);
}

public sealed class DependencyInjectionScopeTestDataSource : DependencyInjectionDataSourceAttribute<IServiceScope>
public sealed class DependencyInjectionClassConstructor : DependencyInjectionDataSourceAttribute<IServiceScope>
{
private readonly IServiceProvider _serviceProvider = BuildServiceProvider();

Expand All @@ -28,7 +29,7 @@ public override IServiceScope CreateScope(DataGeneratorMetadata dataGeneratorMet
}

[EngineTest(ExpectedResult.Pass)]
[DependencyInjectionScopeTestDataSource]
[DependencyInjectionClassConstructor]
public sealed class ActualTestClass(Dependency dependency)
{
[Test]
Expand All @@ -37,5 +38,9 @@ public sealed class ActualTestClass(Dependency dependency)
public void Test1(int testNumber)
{
Console.WriteLine($"Test {testNumber}: Dependency Value = {dependency.Value}");

// With our fix, each test should get a different dependency value (1 and 2)
// Before the fix, both would have gotten the same value (1 and 1)
Assert.That(dependency.Value).IsGreaterThan(0).And.IsLessThanOrEqualTo(2);
}
}
45 changes: 0 additions & 45 deletions TUnit.TestProject/SimpleDIScopeTest.cs

This file was deleted.

Loading