TimeSpanToleranceComparer
using System;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Constraints.Comparers
{
internal static class TimeSpanToleranceComparer
{
[NullableContext(1)]
public static EqualMethodResult Equal(object x, object y, ref Tolerance tolerance, ComparisonState state, NUnitEqualityComparer equalityComparer)
{
object obj = tolerance?.Amount;
bool flag;
if (obj is TimeSpan) {
TimeSpan t = (TimeSpan)obj;
TimeSpan timeSpan;
if (x is DateTime) {
DateTime d = (DateTime)x;
if (y is DateTime) {
DateTime d2 = (DateTime)y;
timeSpan = d - d2;
flag = (timeSpan.Duration() <= t);
goto IL_0097;
}
}
if (x is TimeSpan) {
TimeSpan t2 = (TimeSpan)x;
if (y is TimeSpan) {
TimeSpan t3 = (TimeSpan)y;
timeSpan = t2 - t3;
flag = (timeSpan.Duration() <= t);
goto IL_0097;
}
}
return EqualMethodResult.TypesNotSupported;
}
return EqualMethodResult.TypesNotSupported;
IL_0097:
if (!flag)
return EqualMethodResult.ComparedNotEqual;
return EqualMethodResult.ComparedEqual;
}
}
}