38 lines
1.5 KiB
C#
38 lines
1.5 KiB
C#
using System.Reflection;
|
|
using System.Runtime.Versioning;
|
|
using System.Text.Json;
|
|
|
|
namespace GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests.Stdio;
|
|
|
|
public sealed class ProcessStartupTests
|
|
{
|
|
[Theory]
|
|
[InlineData(false, "")]
|
|
[InlineData(false, "scaffold input\nanother line\n")]
|
|
[InlineData(true, "")]
|
|
[InlineData(true, "scaffold input\nanother line\n")]
|
|
public async Task ServerHandlesEmptyEofQuietlyButDoesNotDiscardInvalidInput(bool independentWorkingDirectory, string input)
|
|
{
|
|
Assert.Equal(".NETCoreApp,Version=v10.0",
|
|
typeof(ProcessStartupTests).Assembly.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName);
|
|
Assert.Equal(".NETCoreApp,Version=v10.0",
|
|
Assembly.LoadFile(Path.Combine(McpProcess.ServerDirectory, McpProcess.ServerName + ".dll"))
|
|
.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName);
|
|
|
|
await using var server = new McpProcess(independentWorkingDirectory);
|
|
if (input.Length > 0)
|
|
{
|
|
await server.SendAsync(input, delimiter: "");
|
|
for (var i = 0; i < 2; i++)
|
|
{
|
|
var response = await server.ReadAsync();
|
|
Assert.Equal(JsonValueKind.Null, response.GetProperty("id").ValueKind);
|
|
Assert.Equal(-32700, response.GetProperty("error").GetProperty("code").GetInt32());
|
|
}
|
|
}
|
|
|
|
Assert.Empty(await server.FinishAsync());
|
|
server.AssertNoMoreResponses();
|
|
}
|
|
}
|