mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 08:18:00 +00:00
Added a NUnit test project for the whole solution
This commit is contained in:
6 files changed
+135
-1
No files matched your search
@@ -80,7 +80,21 @@ Notes:
|
|||||||
troubleshooting, no matter whether it came from the MCP server or from the user.
|
troubleshooting, no matter whether it came from the MCP server or from the user.
|
||||||
|
|
||||||
### Running Tests
|
### Running Tests
|
||||||
Currently, no automated test suite exists in the repository.
|
The .NET tests live in `app/Tests`, a single NUnit project that holds the tests of every area; each
|
||||||
|
area gets its own folder and namespace below it rather than a project of its own. Agents run them
|
||||||
|
through the IDE for the same reason they build there:
|
||||||
|
|
||||||
|
```
|
||||||
|
mcp__rider__execute_terminal_command command: "cd app/Tests && dotnet test"
|
||||||
|
```
|
||||||
|
|
||||||
|
An assembly-wide `[SetUpFixture]` in `app/Tests/TestHost.cs` fills the static application state that
|
||||||
|
the app itself only fills while starting up, `Program.LOGGER_FACTORY` above all. Types that
|
||||||
|
initialize a static logger from it — `Settings.Provider` among them — otherwise die in their type
|
||||||
|
initializer before the first assertion. Prefer writing new code so that it does not reach for such
|
||||||
|
statics at all.
|
||||||
|
|
||||||
|
The Rust tests run with `cargo test` in `runtime/`, through the `rustrover` MCP server.
|
||||||
|
|
||||||
## Architecture Details
|
## Architecture Details
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedTools", "SharedTools\
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceGeneratedMappings", "SourceGeneratedMappings\SourceGeneratedMappings.csproj", "{4D7141D5-9C22-4D85-B748-290D15FF484C}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceGeneratedMappings", "SourceGeneratedMappings\SourceGeneratedMappings.csproj", "{4D7141D5-9C22-4D85-B748-290D15FF484C}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{CD46329B-D135-4594-9A70-55D3480F8FEE}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -36,6 +38,10 @@ Global
|
|||||||
{4D7141D5-9C22-4D85-B748-290D15FF484C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{4D7141D5-9C22-4D85-B748-290D15FF484C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{4D7141D5-9C22-4D85-B748-290D15FF484C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{4D7141D5-9C22-4D85-B748-290D15FF484C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{4D7141D5-9C22-4D85-B748-290D15FF484C}.Release|Any CPU.Build.0 = Release|Any CPU
|
{4D7141D5-9C22-4D85-B748-290D15FF484C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{CD46329B-D135-4594-9A70-55D3480F8FEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{CD46329B-D135-4594-9A70-55D3480F8FEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{CD46329B-D135-4594-9A70-55D3480F8FEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{CD46329B-D135-4594-9A70-55D3480F8FEE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
|||||||
@@ -82,6 +82,15 @@
|
|||||||
<Folder Include="Plugins\assistants\assets\" />
|
<Folder Include="Plugins\assistants\assets\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The test project has to reach Program.LOGGER_FACTORY. Program is internal, and it stays that
|
||||||
|
way: it is the entry point, not API. Several types initialize a static logger field from that
|
||||||
|
factory, so a test process must assign it before it touches any of them.
|
||||||
|
-->
|
||||||
|
<ItemGroup>
|
||||||
|
<InternalsVisibleTo Include="Tests" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Read the meta data file -->
|
<!-- Read the meta data file -->
|
||||||
<Target Name="ReadMetaData" BeforeTargets="BeforeBuild">
|
<Target Name="ReadMetaData" BeforeTargets="BeforeBuild">
|
||||||
<Error Text="The ../../metadata.txt file was not found!" Condition="!Exists('../../metadata.txt')" />
|
<Error Text="The ../../metadata.txt file was not found!" Condition="!Exists('../../metadata.txt')" />
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using AIStudio.Provider;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
|
namespace AIStudio.Tests.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks the test harness itself, before any test states something about the app.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Three things have to hold before a capability test can mean anything: the app assembly is
|
||||||
|
/// referenced, this project counts as a friend assembly, and the assembly-wide setup has run. When
|
||||||
|
/// one of them is missing, the failure looks like a broken rule rather than a broken harness, which
|
||||||
|
/// is an expensive detour. These two tests make the difference visible right away.
|
||||||
|
///
|
||||||
|
/// Note the fully written type name below. AIStudio.Provider is a namespace and AIStudio.Settings
|
||||||
|
/// .Provider is a type; inside a namespace under AIStudio, the namespace wins the lookup. That is a
|
||||||
|
/// property of the app's own naming, not of the tests.
|
||||||
|
/// </remarks>
|
||||||
|
[TestFixture]
|
||||||
|
public sealed class TestHarnessTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TheStaticApplicationStateIsAvailable()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Settings.Provider initializes a static logger from Program.LOGGER_FACTORY. Touching it
|
||||||
|
// without the assembly-wide setup throws a TypeInitializationException.
|
||||||
|
//
|
||||||
|
Assert.That(AIStudio.Settings.Provider.NONE.UsedLLMProvider, Is.EqualTo(LLMProviders.NONE));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TheCapabilityApiOfTheAppIsReachable()
|
||||||
|
{
|
||||||
|
var capabilities = LLMProviders.OPEN_AI.GetModelCapabilities(new Model("gpt-5.1", null));
|
||||||
|
|
||||||
|
Assert.That(capabilities, Does.Contain(Capability.FUNCTION_CALLING));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deliberately without a namespace: NUnit then applies this fixture to the whole assembly, so every
|
||||||
|
// test -- the ones written today and the ones written later in some other folder -- starts with the
|
||||||
|
// static state below already in place. A second setup fixture would only ever be needed for state
|
||||||
|
// that must not leak between areas.
|
||||||
|
//
|
||||||
|
namespace AIStudio.Tests;
|
||||||
|
|
||||||
|
[SetUpFixture]
|
||||||
|
public sealed class TestHost
|
||||||
|
{
|
||||||
|
[OneTimeSetUp]
|
||||||
|
public void PrepareStaticApplicationState()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// A number of types in the app hold a static logger field that is initialized from
|
||||||
|
// Program.LOGGER_FACTORY, among them Settings.Provider. The app assigns that factory while
|
||||||
|
// Kestrel comes up; in a test process nobody does, so it stays null and the first touch of
|
||||||
|
// such a type dies inside its type initializer -- before a single assertion runs. A factory
|
||||||
|
// that writes nowhere is all it takes to get past that.
|
||||||
|
//
|
||||||
|
Program.LOGGER_FACTORY = NullLoggerFactory.Instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<RootNamespace>AIStudio.Tests</RootNamespace>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="10.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.10.0" />
|
||||||
|
<!--
|
||||||
|
Pinned below 4.6.0 on purpose, verified by bisecting 4.4.0, 4.5.0, 4.5.1, 4.6.0 and 4.6.1
|
||||||
|
against the .NET 9 SDK (9.0.120, C# 13): from 4.6.0 on, the compiler no longer picks
|
||||||
|
Assert.That<TActual>(TActual, IResolveConstraint, ...) for a plain value. 4.6.0 added
|
||||||
|
Assert.That(Action, ...) and Assert.That<T>(Func<T>, ...) alongside it, and the value
|
||||||
|
overload drops out of the candidate set, so even Assert.That(1, Is.EqualTo(1)) fails with
|
||||||
|
"argument 1: cannot convert int to System.Action", a message that points nowhere near the
|
||||||
|
real cause. Re-test the newest version whenever the .NET SDK is raised.
|
||||||
|
-->
|
||||||
|
<PackageReference Include="NUnit" Version="4.5.1" />
|
||||||
|
<PackageReference Include="NUnit.Analyzers" Version="4.14.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="NUnit3TestAdapter" Version="6.3.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MindWork AI Studio\MindWork AI Studio.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Using Include="NUnit.Framework" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
Reference in new issue
Block a user