Greenfield C# app reading industrial machine data over pluggable protocols. M1 walking skeleton: MTConnect plugin polls a machine, Avalonia dashboard shows live last datum. Build 0 warn/0 err on net48 + net8.0 (Linux), 115 unit tests + 2 docker-gated integration tests. Projects: - Junction.Domain (netstandard2.0): Result<T>, models, IProtocolDriver, IMachineRepository, plugin manifest. Zero package deps. - Junction.Core (netstandard2.0): PollingEngine, PluginLoader (Assembly.LoadFrom), MachineMonitor, DI extensions. - Junction.Persistence (netstandard2.0): SqliteMachineRepository (Dapper), schema, connection factory. Provider-swap seam to SQL Server. - Junction.Protocols.MTConnect (netstandard2.0): HTTP driver + namespace- version-agnostic parser (MTConnect 1.7 + 2.0). Runtime plugin. - Junction.App (net48;net8.0): Avalonia MVVM, live dashboard, NLog, DI root. - Junction.Tests (net8.0): xUnit + Moq, 117 tests. - mock/: docker-compose MTConnect agent (ladder99/agent). Target net48 for Windows 7/8 fleet compatibility. Avalonia pinned 11.3.x. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
75 lines
2.5 KiB
C#
75 lines
2.5 KiB
C#
using Junction.Domain.Protocols;
|
|
using Xunit;
|
|
|
|
namespace Junction.Tests.Unit
|
|
{
|
|
/// <summary>
|
|
/// Tests for the plugin manifest POCO models. Data-only: no serialization here
|
|
/// (JSON parse lives in Core). Covers construction, immutability, null handling,
|
|
/// and the manifest+path pairing of <see cref="PluginDescriptor"/>.
|
|
/// </summary>
|
|
public class PluginManifestTests
|
|
{
|
|
[Fact]
|
|
public void Manifest_Ctor_HoldsAllValues()
|
|
{
|
|
var m = new PluginManifest(
|
|
"mtconnect",
|
|
"MTConnect Driver",
|
|
"Junction.Protocols.MTConnect.dll",
|
|
"Junction.Protocols.MTConnect.MTConnectDriverFactory",
|
|
"1.0");
|
|
|
|
Assert.Equal("mtconnect", m.ProtocolId);
|
|
Assert.Equal("MTConnect Driver", m.DisplayName);
|
|
Assert.Equal("Junction.Protocols.MTConnect.dll", m.AssemblyFile);
|
|
Assert.Equal("Junction.Protocols.MTConnect.MTConnectDriverFactory", m.EntryTypeName);
|
|
Assert.Equal("1.0", m.ApiVersion);
|
|
}
|
|
|
|
[Fact]
|
|
public void Manifest_NullStrings_DefaultToEmpty()
|
|
{
|
|
var m = new PluginManifest(null!, null!, null!, null!, null!);
|
|
|
|
Assert.Equal("", m.ProtocolId);
|
|
Assert.Equal("", m.DisplayName);
|
|
Assert.Equal("", m.AssemblyFile);
|
|
Assert.Equal("", m.EntryTypeName);
|
|
Assert.Equal("", m.ApiVersion);
|
|
}
|
|
|
|
[Fact]
|
|
public void Manifest_Properties_AreGetOnly()
|
|
{
|
|
var props = typeof(PluginManifest).GetProperties();
|
|
Assert.All(props, p => Assert.Null(p.SetMethod));
|
|
}
|
|
|
|
[Fact]
|
|
public void Descriptor_Ctor_PairsManifestAndPath()
|
|
{
|
|
var m = new PluginManifest("mtconnect", "MTConnect", "p.dll", "T", "1.0");
|
|
var d = new PluginDescriptor(m, "/opt/junction/plugins/mtconnect/p.dll");
|
|
|
|
Assert.Same(m, d.Manifest);
|
|
Assert.Equal("/opt/junction/plugins/mtconnect/p.dll", d.AssemblyPath);
|
|
}
|
|
|
|
[Fact]
|
|
public void Descriptor_NullPath_DefaultsToEmpty()
|
|
{
|
|
var m = new PluginManifest("mtconnect", "MTConnect", "p.dll", "T", "1.0");
|
|
var d = new PluginDescriptor(m, null!);
|
|
|
|
Assert.Equal("", d.AssemblyPath);
|
|
}
|
|
|
|
[Fact]
|
|
public void Descriptor_Properties_AreGetOnly()
|
|
{
|
|
var props = typeof(PluginDescriptor).GetProperties();
|
|
Assert.All(props, p => Assert.Null(p.SetMethod));
|
|
}
|
|
}
|
|
}
|