-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClaudeClientTests.cs
More file actions
71 lines (59 loc) · 2.4 KB
/
ClaudeClientTests.cs
File metadata and controls
71 lines (59 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using ManagedCode.ClaudeCodeSharpSDK.Client;
using ManagedCode.ClaudeCodeSharpSDK.Configuration;
using ManagedCode.ClaudeCodeSharpSDK.Execution;
using ManagedCode.ClaudeCodeSharpSDK.Tests.Shared;
namespace ManagedCode.ClaudeCodeSharpSDK.Tests.Unit;
public class ClaudeClientTests
{
private const string CallStartAsyncFirstMessageFragment = "Call StartAsync first";
private const string ExistingSessionId = "session-42";
[Test]
public async Task StartThread_WithAutoStartDisabled_Throws()
{
using var client = new ClaudeClient(
new ClaudeClientOptions
{
AutoStart = false,
ClaudeOptions = new ClaudeOptions { ClaudeExecutablePath = TestConstants.ClaudeExecutablePath },
},
exec: null);
var exception = await Assert.That(() =>
{
client.StartThread();
}).ThrowsException();
await Assert.That(exception).IsTypeOf<InvalidOperationException>();
await Assert.That(exception!.Message).Contains(CallStartAsyncFirstMessageFragment);
}
[Test]
public async Task StartStopAndDispose_TrackConnectionState()
{
using var client = new ClaudeClient(
new ClaudeClientOptions
{
AutoStart = true,
ClaudeOptions = new ClaudeOptions { ClaudeExecutablePath = TestConstants.ClaudeExecutablePath },
},
exec: null);
await Assert.That(client.State).IsEqualTo(ClaudeClientState.Disconnected);
await client.StartAsync();
await Assert.That(client.State).IsEqualTo(ClaudeClientState.Connected);
await client.StopAsync();
await Assert.That(client.State).IsEqualTo(ClaudeClientState.Disconnected);
client.Dispose();
await Assert.That(client.State).IsEqualTo(ClaudeClientState.Disposed);
}
[Test]
public async Task ResumeThread_SeedsExistingThreadId()
{
var exec = new ClaudeExec(TestConstants.ClaudeExecutablePath);
using var client = new ClaudeClient(
new ClaudeClientOptions
{
AutoStart = true,
ClaudeOptions = new ClaudeOptions { ClaudeExecutablePath = TestConstants.ClaudeExecutablePath },
},
exec);
using var thread = client.ResumeThread(ExistingSessionId);
await Assert.That(thread.Id).IsEqualTo(ExistingSessionId);
}
}