36 lines
975 B
C#
36 lines
975 B
C#
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();
|
|
}
|
|
}
|