Files
Chronos/tests/Titano.Testing/Attributes.cs
T
Claude 83a54fb57b 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
2026-10-02 08:59:40 +00:00

56 lines
2.4 KiB
C#

namespace Titano.Testing;
/// <summary>Marks a public method as a test. The method may be sync or return <see cref="Task"/>/<see cref="ValueTask"/>.</summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class TestAttribute : Attribute;
/// <summary>Marks a parameterised test; each <see cref="CaseAttribute"/> is one execution.</summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class TheoryAttribute : Attribute;
/// <summary>One set of arguments for a <see cref="TheoryAttribute"/> test.</summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public sealed class CaseAttribute(params object?[] arguments) : Attribute
{
public object?[] Arguments { get; } = arguments ?? [null];
/// <summary>Optional display name for the case.</summary>
public string? Name { get; init; }
}
/// <summary>Skips a test (or every test of a class) with a reason.</summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
public sealed class SkipAttribute(string reason) : Attribute
{
public string Reason { get; } = reason;
}
/// <summary>Fails the test when it runs longer than the given number of milliseconds.</summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
public sealed class TimeoutAttribute(int milliseconds) : Attribute
{
public int Milliseconds { get; } = milliseconds;
}
/// <summary>Tags a test or class; filters accept <c>category:name</c>.</summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
public sealed class CategoryAttribute(string name) : Attribute
{
public string Name { get; } = name;
}
/// <summary>Runs only on Windows; skipped elsewhere.</summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
public sealed class WindowsOnlyAttribute : Attribute;
/// <summary>Runs only when the environment variable is set and non-empty; skipped otherwise.</summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
public sealed class RequiresEnvironmentAttribute(string variable) : Attribute
{
public string Variable { get; } = variable;
}
/// <summary>Tests of this class never run concurrently with any other test.</summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public sealed class SerialAttribute : Attribute;