mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 13:27:21 +00:00
34 lines
2.0 KiB
C#
34 lines
2.0 KiB
C#
namespace AIStudio.Tests.Serialization;
|
|
|
|
/// <summary>
|
|
/// Checks that the contracts AI Studio uses for its JSON match those reflection builds.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// AI Studio wrote all its files with contracts which reflection built. Any other contract, e.g., one which
|
|
/// source generation builds, has to match them in every detail, or AI Studio no longer reads what it wrote
|
|
/// before: a property with another name, without a setter, or without its converter silently loses its value.
|
|
/// </remarks>
|
|
[TestFixture]
|
|
public sealed class JsonContractTests
|
|
{
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.Stored))]
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.ProviderRequests))]
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.ProviderAnswers))]
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.RuntimeRequests))]
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.RuntimeAnswers))]
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.ServiceRequests))]
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.ServiceAnswers))]
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.VisualBriefingStored))]
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.VisualBriefingHashed))]
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.VisualBriefingAnswers))]
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.ModelAnswers))]
|
|
[TestCaseSource(typeof(JsonTestRoots), nameof(JsonTestRoots.ModelPrompts))]
|
|
public void TheContractsMatchThoseOfReflection(JsonTestRoot root)
|
|
{
|
|
var baseline = JsonReflectionBaseline.Of(root.Options);
|
|
var expected = JsonTypeGraph.Collect(root.Type, baseline).Select(type => JsonContractDescription.Describe(baseline.GetTypeInfo(type)));
|
|
var actual = JsonTypeGraph.Collect(root.Type, root.Options).Select(type => JsonContractDescription.Describe(root.Options.GetTypeInfo(type)));
|
|
|
|
Assert.That(actual, Is.EqualTo(expected));
|
|
}
|
|
} |