Add EndSessionTool (no params, returns ok; relay closes on this tool name)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System.Text.Json;
|
||||
using backend.Tools;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace backend.tests;
|
||||
|
||||
public class EndSessionToolTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Returns_ok_true()
|
||||
{
|
||||
var tool = new EndSessionTool();
|
||||
var ctx = new DeviceContext(Guid.NewGuid(), Guid.NewGuid(), new NoopChannel());
|
||||
|
||||
var res = await tool.ExecuteAsync(
|
||||
new ToolInvocation("call_1", JsonDocument.Parse("{}").RootElement), ctx, default);
|
||||
|
||||
res.Output.GetProperty("ok").GetBoolean().Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Name_and_runs_during_response_match_spec()
|
||||
{
|
||||
var tool = new EndSessionTool();
|
||||
tool.Name.Should().Be("end_session");
|
||||
tool.RunsDuringResponse.Should().BeFalse();
|
||||
}
|
||||
|
||||
private class NoopChannel : IDeviceChannel
|
||||
{
|
||||
public Task<JsonElement> CallPiToolAsync(string n, JsonElement a, CancellationToken ct)
|
||||
=> throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user