mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-11 08:07:21 +00:00
Adopted further C# 14 and .NET 10 features (#1158)
This commit is contained in:
1 parent
f649febf88
commit
f0fa1411c8
40 files changed
+545
-56
No files matched your search
@@ -0,0 +1,46 @@
|
||||
using AIStudio.Provider;
|
||||
|
||||
namespace AIStudio.Tests.Provider;
|
||||
|
||||
/// <summary>
|
||||
/// Checks how the additional API parameters of a provider are read.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The dialog for providers refuses a parameter named twice, but a configuration plugin brings its
|
||||
/// providers past the dialog. Read anyway, such parameters would leave it open which of the values
|
||||
/// reaches the provider, and they used to break every request with an exception nobody caught.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public sealed class AdditionalApiParametersParserTests
|
||||
{
|
||||
[Test]
|
||||
public void TheParametersAreRead()
|
||||
{
|
||||
var isRead = AdditionalApiParametersParser.TryParse("""
|
||||
"temperature": 0.5,
|
||||
"reasoning": { "effort": "low" }
|
||||
""", out var parameters, out var errorMessage);
|
||||
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(isRead, Is.True);
|
||||
Assert.That(errorMessage, Is.Null);
|
||||
Assert.That(parameters["temperature"], Is.EqualTo(0.5));
|
||||
Assert.That(parameters["reasoning"], Is.EqualTo(new Dictionary<string, object> { ["effort"] = "low" }));
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase("\"temperature\": 0.5, \"temperature\": 0.7", "temperature", TestName = "A parameter named twice")]
|
||||
[TestCase("\"reasoning\": { \"effort\": \"low\", \"effort\": \"high\" }", "effort", TestName = "A field named twice inside a parameter")]
|
||||
public void AParameterNamedTwiceIsRefused(string additionalParameters, string repeatedName)
|
||||
{
|
||||
var isRead = AdditionalApiParametersParser.TryParse(additionalParameters, out var parameters, out var errorMessage);
|
||||
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(isRead, Is.False);
|
||||
Assert.That(parameters, Is.Empty);
|
||||
Assert.That(errorMessage, Does.Contain($"'{repeatedName}'"), "The log names the parameter to correct.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user