audit notes work completed, test fixes work (95% done), new sprints, new data sources setup and configuration
This commit is contained in:
17
src/Plugin/__Tests/StellaOps.Plugin.Sdk.Tests/AGENTS.md
Normal file
17
src/Plugin/__Tests/StellaOps.Plugin.Sdk.Tests/AGENTS.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Plugin SDK Tests - AGENTS.md
|
||||
|
||||
## Module Overview
|
||||
Test project for the Plugin SDK which provides base classes and builders for plugin development.
|
||||
|
||||
## Test Coverage
|
||||
- `PluginInfoBuilderTests` - Tests for the fluent PluginInfo builder (required fields, optional fields, validation)
|
||||
|
||||
## Working Agreements
|
||||
1. Test both success and failure paths for builders
|
||||
2. Verify validation exceptions contain meaningful messages
|
||||
3. Test fluent builder chaining
|
||||
|
||||
## Running Tests
|
||||
```bash
|
||||
dotnet test src/Plugin/__Tests/StellaOps.Plugin.Sdk.Tests/StellaOps.Plugin.Sdk.Tests.csproj
|
||||
```
|
||||
@@ -0,0 +1,115 @@
|
||||
using StellaOps.Plugin.Sdk;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Plugin.Sdk.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for PluginInfoBuilder.
|
||||
/// </summary>
|
||||
public sealed class PluginInfoBuilderTests
|
||||
{
|
||||
[Fact]
|
||||
public void Build_WithRequiredFields_CreatesPluginInfo()
|
||||
{
|
||||
var builder = new PluginInfoBuilder()
|
||||
.WithId("com.stellaops.test.plugin")
|
||||
.WithName("Test Plugin")
|
||||
.WithVendor("StellaOps");
|
||||
|
||||
var info = builder.Build();
|
||||
|
||||
Assert.Equal("com.stellaops.test.plugin", info.Id);
|
||||
Assert.Equal("Test Plugin", info.Name);
|
||||
Assert.Equal("StellaOps", info.Vendor);
|
||||
Assert.Equal("1.0.0", info.Version); // Default version
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_WithAllFields_CreatesPluginInfo()
|
||||
{
|
||||
var builder = new PluginInfoBuilder()
|
||||
.WithId("com.example.full.plugin")
|
||||
.WithName("Full Plugin")
|
||||
.WithVersion("2.1.0")
|
||||
.WithVendor("Example Corp")
|
||||
.WithDescription("A fully configured plugin")
|
||||
.WithLicense("MIT")
|
||||
.WithProjectUrl("https://example.com/plugin")
|
||||
.WithIconUrl("https://example.com/icon.png");
|
||||
|
||||
var info = builder.Build();
|
||||
|
||||
Assert.Equal("com.example.full.plugin", info.Id);
|
||||
Assert.Equal("Full Plugin", info.Name);
|
||||
Assert.Equal("2.1.0", info.Version);
|
||||
Assert.Equal("Example Corp", info.Vendor);
|
||||
Assert.Equal("A fully configured plugin", info.Description);
|
||||
Assert.Equal("MIT", info.LicenseId);
|
||||
Assert.Equal("https://example.com/plugin", info.ProjectUrl);
|
||||
Assert.Equal("https://example.com/icon.png", info.IconUrl);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_WithoutId_ThrowsInvalidOperationException()
|
||||
{
|
||||
var builder = new PluginInfoBuilder()
|
||||
.WithName("Test Plugin");
|
||||
|
||||
var ex = Assert.Throws<InvalidOperationException>(() => builder.Build());
|
||||
Assert.Contains("ID", ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_WithoutName_ThrowsInvalidOperationException()
|
||||
{
|
||||
var builder = new PluginInfoBuilder()
|
||||
.WithId("com.test.plugin");
|
||||
|
||||
var ex = Assert.Throws<InvalidOperationException>(() => builder.Build());
|
||||
Assert.Contains("name", ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_WithEmptyId_ThrowsInvalidOperationException()
|
||||
{
|
||||
var builder = new PluginInfoBuilder()
|
||||
.WithId("")
|
||||
.WithName("Test");
|
||||
|
||||
var ex = Assert.Throws<InvalidOperationException>(() => builder.Build());
|
||||
Assert.Contains("ID", ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Builder_IsChainable()
|
||||
{
|
||||
var info = new PluginInfoBuilder()
|
||||
.WithId("com.test.chain")
|
||||
.WithName("Chain Test")
|
||||
.WithVersion("1.0.0")
|
||||
.WithVendor("Test")
|
||||
.WithDescription("desc")
|
||||
.WithLicense("Apache-2.0")
|
||||
.WithProjectUrl("https://test.com")
|
||||
.WithIconUrl("https://test.com/icon")
|
||||
.Build();
|
||||
|
||||
Assert.NotNull(info);
|
||||
Assert.Equal("com.test.chain", info.Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_OptionalFields_CanBeOmitted()
|
||||
{
|
||||
var info = new PluginInfoBuilder()
|
||||
.WithId("com.test.minimal")
|
||||
.WithName("Minimal Plugin")
|
||||
.WithVendor("") // Empty vendor is allowed
|
||||
.Build();
|
||||
|
||||
Assert.Null(info.Description);
|
||||
Assert.Null(info.LicenseId);
|
||||
Assert.Null(info.ProjectUrl);
|
||||
Assert.Null(info.IconUrl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<IsPackable>false</IsPackable>
|
||||
<OutputType>Exe</OutputType>
|
||||
<UseXunitV3>true</UseXunitV3>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
|
||||
<PackageReference Include="Moq" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\StellaOps.Plugin.Sdk\StellaOps.Plugin.Sdk.csproj" />
|
||||
<ProjectReference Include="..\..\StellaOps.Plugin.Abstractions\StellaOps.Plugin.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
|
||||
"diagnosticMessages": true,
|
||||
"parallelizeAssembly": true,
|
||||
"parallelizeTestCollections": true,
|
||||
"maxParallelThreads": -1
|
||||
}
|
||||
Reference in New Issue
Block a user