<PackageReference Include="NUnit" Version="4.3.2" />

ResultState

The ResultState class represents the outcome of running a test. It contains two pieces of information. The Status of the test is an enum indicating whether the test passed, failed, was skipped or was inconclusive. The Label provides a more detailed breakdown for use by client runners.
using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Text; namespace NUnit.Framework.Interfaces { [NullableContext(1)] [Nullable(0)] public class ResultState : IEquatable<ResultState> { public static readonly ResultState Inconclusive = new ResultState(TestStatus.Inconclusive); public static readonly ResultState Skipped = new ResultState(TestStatus.Skipped); public static readonly ResultState Ignored = new ResultState(TestStatus.Skipped, "Ignored"); public static readonly ResultState Explicit = new ResultState(TestStatus.Skipped, "Explicit"); public static readonly ResultState Success = new ResultState(TestStatus.Passed); public static readonly ResultState Warning = new ResultState(TestStatus.Warning); public static readonly ResultState Failure = new ResultState(TestStatus.Failed); public static readonly ResultState Error = new ResultState(TestStatus.Failed, "Error"); public static readonly ResultState Cancelled = new ResultState(TestStatus.Failed, "Cancelled"); public static readonly ResultState NotRunnable = new ResultState(TestStatus.Failed, "Invalid"); public static readonly ResultState ChildFailure = Failure.WithSite(FailureSite.Child); public static readonly ResultState ChildWarning = Warning.WithSite(FailureSite.Child); public static readonly ResultState ChildIgnored = Ignored.WithSite(FailureSite.Child); public static readonly ResultState SetUpFailure = Failure.WithSite(FailureSite.SetUp); public static readonly ResultState SetUpError = Error.WithSite(FailureSite.SetUp); public static readonly ResultState TearDownError = Error.WithSite(FailureSite.TearDown); public TestStatus Status { get; } public string Label { get; } public FailureSite Site { get; } public ResultState(TestStatus status) : this(status, string.Empty, FailureSite.Test) { } [NullableContext(2)] public ResultState(TestStatus status, string label) : this(status, label, FailureSite.Test) { } public ResultState(TestStatus status, FailureSite site) : this(status, string.Empty, site) { } [NullableContext(2)] public ResultState(TestStatus status, string label, FailureSite site) { Status = status; Label = (label ?? string.Empty); Site = site; } public ResultState WithSite(FailureSite site) { return new ResultState(Status, Label, site); } public bool Matches(ResultState other) { if (Status == other.Status) return Label == other.Label; return false; } [NullableContext(2)] public override bool Equals(object obj) { return Equals(obj as ResultState); } [NullableContext(2)] public bool Equals(ResultState other) { if ((object)other != null && Status == other.Status && Label == other.Label) return Site == other.Site; return false; } public override int GetHashCode() { int num = -665355758; num = num * -1521134295 + Status.GetHashCode(); num = num * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Label); return num * -1521134295 + Site.GetHashCode(); } public static bool operator ==(ResultState left, ResultState right) { return left?.Equals(right) ?? ((object)right == null); } public static bool operator !=(ResultState left, ResultState right) { return !(left == right); } public override string ToString() { StringBuilder stringBuilder = new StringBuilder(Status.ToString()); if (Label.Length > 0) stringBuilder.AppendFormat(":{0}", Label); if (Site != 0) stringBuilder.AppendFormat("({0})", Site.ToString()); return stringBuilder.ToString(); } } }