chore: bootstrap repository foundation
Solution layout, build rules with zero-package guard, in-house test framework, localization runtime, brand mark rasteriser with ICO/PNG generation, Core contracts (imaging, video, domain model, TIFF reader), Titano.Tools (make-icon, i18n, xaml-lint, package-guard) and docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
109 files changed
+7523
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace Titano.Testing;
|
||||
|
||||
/// <summary>One discovered executable test (a method, or one case of a theory).</summary>
|
||||
public sealed class TestCase
|
||||
{
|
||||
internal TestCase(Type type, MethodInfo method, object?[]? arguments, string? caseName)
|
||||
{
|
||||
Type = type;
|
||||
Method = method;
|
||||
Arguments = arguments;
|
||||
var suffix = arguments is null ? string.Empty : "(" + (caseName ?? string.Join(", ", arguments.Select(Assert.Format))) + ")";
|
||||
FullName = $"{type.FullName}.{method.Name}{suffix}";
|
||||
Categories = type.GetCustomAttributes<CategoryAttribute>()
|
||||
.Concat(method.GetCustomAttributes<CategoryAttribute>())
|
||||
.Select(c => c.Name)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray();
|
||||
TimeoutMs = method.GetCustomAttribute<TimeoutAttribute>()?.Milliseconds
|
||||
?? type.GetCustomAttribute<TimeoutAttribute>()?.Milliseconds
|
||||
?? 300_000;
|
||||
Serial = type.GetCustomAttribute<SerialAttribute>() is not null;
|
||||
StaticSkipReason = ComputeSkipReason(type, method);
|
||||
}
|
||||
|
||||
public Type Type { get; }
|
||||
public MethodInfo Method { get; }
|
||||
public object?[]? Arguments { get; }
|
||||
public string FullName { get; }
|
||||
public IReadOnlyList<string> Categories { get; }
|
||||
public int TimeoutMs { get; }
|
||||
public bool Serial { get; }
|
||||
public string? StaticSkipReason { get; }
|
||||
|
||||
private static string? ComputeSkipReason(Type type, MethodInfo method)
|
||||
{
|
||||
var skip = method.GetCustomAttribute<SkipAttribute>() ?? type.GetCustomAttribute<SkipAttribute>();
|
||||
if (skip is not null) return skip.Reason;
|
||||
if ((method.GetCustomAttribute<WindowsOnlyAttribute>() ?? type.GetCustomAttribute<WindowsOnlyAttribute>()) is not null
|
||||
&& !OperatingSystem.IsWindows())
|
||||
return "Windows only";
|
||||
foreach (var env in type.GetCustomAttributes<RequiresEnvironmentAttribute>().Concat(method.GetCustomAttributes<RequiresEnvironmentAttribute>()))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(env.Variable)))
|
||||
return $"{env.Variable} not set";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public enum TestOutcome
|
||||
{
|
||||
Passed,
|
||||
Failed,
|
||||
Skipped,
|
||||
}
|
||||
|
||||
public sealed record TestResult(TestCase Test, TestOutcome Outcome, TimeSpan Duration, string? Message, string? StackTrace, string Log);
|
||||
Reference in new issue
Block a user