Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ public static async Task VerifyCodeFixAsync(
{
var test = new CSharpCodeFixTest<TAnalyzer, TCodeFix, LineEndingNormalizingVerifier>
{
TestCode = source,
FixedCode = fixedSource,
TestCode = LineEndingNormalizingVerifier.NormalizeLineEndings(source),
FixedCode = LineEndingNormalizingVerifier.NormalizeLineEndings(fixedSource),
ReferenceAssemblies = ReferenceAssemblies.Net.Net90,
};

if (stubsSource is not null)
{
test.TestState.Sources.Add(stubsSource);
test.FixedState.Sources.Add(stubsSource);
var normalizedStubs = LineEndingNormalizingVerifier.NormalizeLineEndings(stubsSource);
test.TestState.Sources.Add(normalizedStubs);
test.FixedState.Sources.Add(normalizedStubs);
}

test.TestState.AnalyzerConfigFiles.Add(("/.editorconfig", SourceText.From("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public IVerifier PushContext(string context)
return new LineEndingNormalizingVerifierWithContext(_defaultVerifier.PushContext(context));
}

private static string NormalizeLineEndings(string value)
internal static string NormalizeLineEndings(string value)
{
// Normalize all line endings to LF (Unix) for cross-platform consistent comparison
// LF is the universal standard and prevents Windows/Linux test mismatches
Expand Down
15 changes: 15 additions & 0 deletions TUnit.OpenTelemetry.Tests/Helpers/OtlpTraceCaptureServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ public void Start()
_listenTask = Task.Run(ListenLoopAsync);
}

public bool HasRequest(string path)
{
lock (_stateLock)
{
foreach (var existing in _requests)
{
if (existing.Path == path)
{
return true;
}
}
return false;
}
}

public async Task<CapturedRequest> WaitForRequestAsync(string path, int timeoutMs = 5000)
{
var tcs = new TaskCompletionSource<CapturedRequest>(TaskCreationOptions.RunContinuationsAsynchronously);
Expand Down
8 changes: 1 addition & 7 deletions TUnit.OpenTelemetry.Tests/OtlpReceiverForwardingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ public async Task Receiver_WithoutUpstream_DoesNotForward()
await client.PostAsync($"http://127.0.0.1:{receiver.Port}/v1/traces", content);
await receiver.WhenIdle();

// Upstream never told about the receiver — but we assert nothing arrived there.
// Poll briefly to allow any stray forwarding to surface.
var timeout = Task.Delay(200);
var waited = await Task.WhenAny(upstream.WaitForRequestAsync("/v1/traces", timeoutMs: 200), timeout);

// Either the wait timed out (expected) or the request faulted; both prove no forwarding.
await Assert.That(waited).IsEqualTo(timeout);
await Assert.That(upstream.HasRequest("/v1/traces")).IsFalse();
}
}
1 change: 1 addition & 0 deletions TUnit.TestProject/HookExecutorHookTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ protected override async ValueTask ExecuteAsync(Func<ValueTask> action)

[EngineTest(ExpectedResult.Pass)]
[HookExecutor<RecordingHookExecutor_F1ClassLevel>]
[NotInParallel(nameof(HookExecutorHookTests_ClassLevel))]
public class HookExecutorHookTests_ClassLevel
{
[Before(Class)]
Expand Down
8 changes: 5 additions & 3 deletions TUnit.TestProject/KeyedDataSourceTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using TUnit.Core.Interfaces;
using TUnit.TestProject.Attributes;
Expand All @@ -21,7 +22,7 @@ public Task InitializeAsync()
[UnconditionalSuppressMessage("Usage", "TUnit0018:Test methods should not assign instance data")]
public class KeyedDataSourceTests
{
private static readonly List<KeyAwareFixture> AlphaInstances = [];
private static readonly ConcurrentBag<KeyAwareFixture> AlphaInstances = [];

[Test]
[ClassDataSource<KeyAwareFixture>(Shared = SharedType.Keyed, Key = "alpha")]
Expand Down Expand Up @@ -51,7 +52,8 @@ public async Task Key_IsAvailableDuringInitializeAsync(KeyAwareFixture fixture)
[DependsOn(nameof(Key_IsAvailableDuringInitializeAsync))]
public async Task SameKey_ReturnsSameInstance()
{
await Assert.That(AlphaInstances).Count().IsEqualTo(2);
await Assert.That(AlphaInstances[0]).IsSameReferenceAs(AlphaInstances[1]);
var snapshot = AlphaInstances.ToArray();
await Assert.That(snapshot.Length).IsEqualTo(2);
await Assert.That(snapshot[0]).IsSameReferenceAs(snapshot[1]);
}
}
Loading