Files
novelly/tests/Novelly.Api.Tests/AnthropicClientTests.cs
T
James Wampler 23348327a9 Remove Scenes, group beats by multiple characters; strip comments repo-wide
Drop the Scene entity/grouping in favor of chapters carrying prose directly
and beats belonging to many characters. Add markdown editor + character
multi-select components to the web client. Remove all XML doc and inline
comments across the touched C#/TS/CSS files in favor of self-documenting
names, and record that convention in CLAUDE.md. Add .mcp.json (local MCP
server config, no secrets) and ignore .idea/.
2026-08-11 21:05:13 -07:00

37 lines
1.2 KiB
C#

using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Novelly.Api.Agent;
using Novelly.Api.Common;
namespace Novelly.Api.Tests;
[TestFixture]
public class AnthropicClientTests
{
[Test]
public void Constructing_without_a_key_does_not_throw() =>
Assert.That(
() => new AnthropicAgentModelClient(Options.Create(new AgentOptions()), NullLogger<AnthropicAgentModelClient>.Instance),
Throws.Nothing);
[Test]
public void Sending_without_a_key_reports_a_configuration_problem()
{
var previous = Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY");
Environment.SetEnvironmentVariable("ANTHROPIC_API_KEY", null);
try
{
var client = new AnthropicAgentModelClient(Options.Create(new AgentOptions()), NullLogger<AnthropicAgentModelClient>.Instance);
Assert.That(
async () => await client.CompleteAsync("system", [], []),
Throws.TypeOf<AgentNotConfiguredException>().With.Message.Contains("ANTHROPIC_API_KEY"));
}
finally
{
Environment.SetEnvironmentVariable("ANTHROPIC_API_KEY", previous);
}
}
}