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 @@ -19,7 +19,7 @@ public async Task RunAsyncContinuesAfterSkippedItem()
new LocalizationRequest(first, "schinese", null, CreateOptions()),
new LocalizationRequest(second, "schinese", null, CreateOptions()),
]),
new Progress<TranslationProgress>(progressEvents.Add),
new ListProgress(progressEvents),
CancellationToken.None);

Assert.True(results[0].Succeeded);
Expand Down Expand Up @@ -119,14 +119,6 @@ public Task<string> CompleteTextAsync(
}
}

private sealed class ListProgress(List<TranslationProgress> events) : IProgress<TranslationProgress>
{
public void Report(TranslationProgress value)
{
events.Add(value);
}
}

private sealed class QueuingSynchronizationContext : SynchronizationContext
{
public override void Post(SendOrPostCallback d, object? state)
Expand Down
12 changes: 12 additions & 0 deletions tests/BSPLocalizationTools.Tests/ListProgress.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace BSPLocalizationTools.Tests;

// Synchronous IProgress so progress events are recorded before the awaited call returns.
// Progress<T> posts callbacks to the captured SynchronizationContext, which under xUnit can
// deliver them after the test's assertions have already run.
internal sealed class ListProgress(List<TranslationProgress> events) : IProgress<TranslationProgress>
{
public void Report(TranslationProgress value)
{
events.Add(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task RunAsyncReportsStagesAndOutputPath()
"schinese",
null,
new LLMOptions("gpt-test", "sk-", null, null, "medium", null)),
new Progress<TranslationProgress>(progressEvents.Add),
new ListProgress(progressEvents),
CancellationToken.None);

Assert.Equal(Path.Combine(temp.Path, "fake_map_dictionary_schinese.csv"), result.OutputPath);
Expand Down
Loading