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>
61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using System;
|
|
using Junction.Domain;
|
|
using Xunit;
|
|
|
|
namespace Junction.Tests.Unit
|
|
{
|
|
public class OperationErrorTests
|
|
{
|
|
[Fact]
|
|
public void Ctor_StoresFields()
|
|
{
|
|
var err = new OperationError("E01", "Repo", "boom");
|
|
|
|
Assert.Equal("E01", err.Code);
|
|
Assert.Equal("Repo", err.Source);
|
|
Assert.Equal("boom", err.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void Ctor_SetsTimestamp()
|
|
{
|
|
var before = DateTime.Now;
|
|
var err = new OperationError("E", "S", "M");
|
|
var after = DateTime.Now;
|
|
|
|
Assert.InRange(err.At, before, after);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null, null)]
|
|
[InlineData(null, "S", null)]
|
|
public void Ctor_NullsBecomeEmptyStrings(string? code, string? source, string? message)
|
|
{
|
|
var err = new OperationError(code!, source!, message!);
|
|
|
|
Assert.NotNull(err.Code);
|
|
Assert.NotNull(err.Source);
|
|
Assert.NotNull(err.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void Of_CreatesErrorWithEmptyCode()
|
|
{
|
|
var err = OperationError.Of("Repo", "boom");
|
|
|
|
Assert.Equal("", err.Code);
|
|
Assert.Equal("Repo", err.Source);
|
|
Assert.Equal("boom", err.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void ToString_ContainsFields()
|
|
{
|
|
var err = new OperationError("E01", "Repo", "boom");
|
|
|
|
Assert.Contains("E01", err.ToString());
|
|
Assert.Contains("Repo", err.ToString());
|
|
Assert.Contains("boom", err.ToString());
|
|
}
|
|
}
|
|
}
|