AssertionResult
The AssertionResult class represents the result of a single assertion.
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Interfaces
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public class AssertionResult : IEquatable<AssertionResult>
{
public AssertionStatus Status { get; }
public string Message { get; }
[System.Runtime.CompilerServices.Nullable(2)]
[field: System.Runtime.CompilerServices.Nullable(2)]
public string StackTrace {
[System.Runtime.CompilerServices.NullableContext(2)]
get;
}
public AssertionResult(AssertionStatus status, string message, [System.Runtime.CompilerServices.Nullable(2)] string stackTrace)
{
Status = status;
Message = message;
StackTrace = stackTrace;
}
[System.Runtime.CompilerServices.NullableContext(2)]
public override bool Equals(object obj)
{
return Equals(obj as AssertionResult);
}
[System.Runtime.CompilerServices.NullableContext(2)]
public bool Equals(AssertionResult other)
{
if (other != null && Status == other.Status && Message == other.Message)
return StackTrace == other.StackTrace;
return false;
}
public override int GetHashCode()
{
int num = -783279553;
num = num * -1521134295 + Status.GetHashCode();
num = num * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Message);
return num * -1521134295 + EqualityComparer<string>.Default.GetHashCode(StackTrace ?? string.Empty);
}
public override string ToString()
{
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(9, 2);
defaultInterpolatedStringHandler.AppendLiteral("Assert ");
defaultInterpolatedStringHandler.AppendFormatted(Status);
defaultInterpolatedStringHandler.AppendLiteral(": ");
defaultInterpolatedStringHandler.AppendFormatted(Message);
return defaultInterpolatedStringHandler.ToStringAndClear() + Environment.NewLine + StackTrace;
}
}
}