Skip to content
Merged
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
11 changes: 10 additions & 1 deletion BlogWriter.Tests/BlogWorkflowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public async Task RunAsync_RejectedInitialDraftGetsOneRevisionAndNoSecondReview(
Assert.Equal("draft-2", session.State.Draft);
Assert.Equal("Please revise the introduction.", session.State.ReviewNotes);
Assert.Equal(2, author.Calls);
Assert.Equal(2, author.ReviewNotesSeen.Count);
Assert.Equal("", author.ReviewNotesSeen[0]);
Assert.Equal("Please revise the introduction.", author.ReviewNotesSeen[1]);
Assert.Equal(1, reviewer.Calls);
Assert.Contains(output.Updates, update =>
update.Kind == WorkflowOutputKind.Lifecycle &&
Expand All @@ -74,13 +77,17 @@ public async Task RunAsync_RejectedRevisionWithoutReplacementKeepsLatestDraftAnd
author,
reviewer,
NullLogger<BlogWorkflow>.Instance);
var output = new WorkflowOutputCollector();

var service = new BlogWriterSessionService(workflow, new RecordingStore());
BlogSession session = await service.StartAsync("topic");
BlogSession session = await service.StartAsync("topic", output: output);

Assert.Equal("draft-1", session.State.Draft);
Assert.Equal(2, author.Calls);
Assert.Equal(1, reviewer.Calls);
Assert.Contains(output.Updates, update =>
update.Kind == WorkflowOutputKind.Lifecycle &&
update.Outcome == WorkflowOutputOutcome.Success);
}

private sealed class TestBlogger : IBloggerAgent
Expand Down Expand Up @@ -113,13 +120,15 @@ private sealed class TestAuthor(params string?[] drafts) : IAuthorAgent
private readonly IReadOnlyList<string?> _drafts = drafts;

public int Calls { get; private set; }
public List<string> ReviewNotesSeen { get; } = [];

public Task<string?> InvokeAsync(ResearchState state, CancellationToken cancellationToken = default) =>
Task.FromResult(_drafts[Math.Min(Calls, _drafts.Count - 1)]);

public Task<ResearchState> AuthorNodeAsync(ResearchState state, CancellationToken cancellationToken = default)
{
string? draft = _drafts[Math.Min(Calls, _drafts.Count - 1)];
ReviewNotesSeen.Add(state.ReviewNotes);
Calls++;
state.RevisionNumber++;
if (!string.IsNullOrEmpty(draft))
Expand Down
Loading