diff --git a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.Be.cs b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.Be.cs index 02137226..c47bfbe2 100644 --- a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.Be.cs +++ b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.Be.cs @@ -1,7 +1,5 @@ -using System; -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; using Testably.Expectations.Core; -using Testably.Expectations.Core.Constraints; using Testably.Expectations.Formatting; using Testably.Expectations.Options; using Testably.Expectations.Results; @@ -22,7 +20,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsValueConstraint(expected, options)) + .AddConstraint(new GenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -39,7 +41,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsValueConstraint(expected, options)) + .AddConstraint(new GenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -56,7 +62,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsValueConstraint(expected, options)) + .AddConstraint(new GenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -73,7 +83,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsValueConstraint(expected, options)) + .AddConstraint(new GenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -90,7 +104,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsValueConstraint(expected, options)) + .AddConstraint(new GenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -107,7 +125,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsValueConstraint(expected, options)) + .AddConstraint(new GenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -124,7 +146,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsValueConstraint(expected, options)) + .AddConstraint(new GenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -141,7 +167,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsValueConstraint(expected, options)) + .AddConstraint(new GenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -158,7 +188,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => a.Equals(e) || (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsValueConstraint(expected, options)) + .AddConstraint(new GenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -175,7 +209,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => a.Equals(e) || (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsValueConstraint(expected, options)) + .AddConstraint(new GenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -192,7 +230,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsValueConstraint(expected, options)) + .AddConstraint(new GenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -209,7 +251,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNullableValueConstraint(expected, options)) + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -226,7 +272,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNullableValueConstraint(expected, options)) + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -243,7 +293,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNullableValueConstraint(expected, options)) + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -260,7 +314,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNullableValueConstraint(expected, options)) + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -277,7 +335,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNullableValueConstraint(expected, options)) + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -294,7 +356,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNullableValueConstraint(expected, options)) + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -311,7 +377,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNullableValueConstraint(expected, options)) + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -328,7 +398,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNullableValueConstraint(expected, options)) + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -345,7 +419,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => a.Equals(e) || (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNullableValueConstraint(expected, options)) + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -362,7 +440,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => a.Equals(e) || (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNullableValueConstraint(expected, options)) + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -379,7 +461,11 @@ public static NumberToleranceResult> Be( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNullableValueConstraint(expected, options)) + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(Be), doNotPopulateThisValue), source, options); @@ -397,7 +483,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotValueConstraint(unexpected, options)) + .AddConstraint(new GenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -415,7 +505,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotValueConstraint(unexpected, options)) + .AddConstraint(new GenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -433,7 +527,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotValueConstraint(unexpected, options)) + .AddConstraint(new GenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -451,7 +549,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotValueConstraint(unexpected, options)) + .AddConstraint(new GenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -469,7 +571,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotValueConstraint(unexpected, options)) + .AddConstraint(new GenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -487,7 +593,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotValueConstraint(unexpected, options)) + .AddConstraint(new GenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -505,7 +615,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotValueConstraint(unexpected, options)) + .AddConstraint(new GenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -523,7 +637,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotValueConstraint(unexpected, options)) + .AddConstraint(new GenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -541,7 +659,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => a.Equals(e) || (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotValueConstraint(unexpected, options)) + .AddConstraint(new GenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -559,7 +681,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => a.Equals(e) || (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotValueConstraint(unexpected, options)) + .AddConstraint(new GenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -577,7 +703,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotValueConstraint(unexpected, options)) + .AddConstraint(new GenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -595,7 +725,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotNullableValueConstraint(unexpected, options)) + .AddConstraint(new NullableGenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -613,7 +747,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotNullableValueConstraint(unexpected, options)) + .AddConstraint(new NullableGenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -631,7 +769,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotNullableValueConstraint(unexpected, options)) + .AddConstraint(new NullableGenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -649,7 +791,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotNullableValueConstraint(unexpected, options)) + .AddConstraint(new NullableGenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -667,7 +813,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotNullableValueConstraint(unexpected, options)) + .AddConstraint(new NullableGenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -685,7 +835,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotNullableValueConstraint(unexpected, options)) + .AddConstraint(new NullableGenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -703,7 +857,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotNullableValueConstraint(unexpected, options)) + .AddConstraint(new NullableGenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -721,7 +879,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotNullableValueConstraint(unexpected, options)) + .AddConstraint(new NullableGenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -739,7 +901,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => a.Equals(e) || (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotNullableValueConstraint(unexpected, options)) + .AddConstraint(new NullableGenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -757,7 +923,11 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => a.Equals(e) || (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotNullableValueConstraint(unexpected, options)) + .AddConstraint(new NullableGenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); @@ -775,89 +945,13 @@ public static NumberToleranceResult> NotBe( NumberTolerance options = new( (a, e, t) => (a > e ? a - e : e - a) <= (t ?? 0)); return new NullableNumberToleranceResult>(source.ExpectationBuilder - .AddConstraint(new IsNotNullableValueConstraint(unexpected, options)) + .AddConstraint(new NullableGenericConstraint( + unexpected, + u => $"not be {Formatter.Format(u)}{options}", + (a, u) => !options.IsWithinTolerance(a, u), + (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBe), doNotPopulateThisValue), source, options); } - - private readonly struct IsValueConstraint( - TNumber? expected, - NumberTolerance options) - : IValueConstraint - where TNumber : struct, IComparable - { - public ConstraintResult IsMetBy(TNumber actual) - { - if (options.IsWithinTolerance(actual, expected)) - { - return new ConstraintResult.Success(actual, ToString()); - } - - return new ConstraintResult.Failure(ToString(), $"found {Formatter.Format(actual)}"); - } - - public override string ToString() - => $"be {Formatter.Format(expected)}{options}"; - } - - private readonly struct IsNullableValueConstraint( - TNumber? expected, - NumberTolerance options) - : IValueConstraint - where TNumber : struct, IComparable - { - public ConstraintResult IsMetBy(TNumber? actual) - { - if (options.IsWithinTolerance(actual, expected)) - { - return new ConstraintResult.Success(actual, ToString()); - } - - return new ConstraintResult.Failure(ToString(), $"found {Formatter.Format(actual)}"); - } - - public override string ToString() - => $"be {Formatter.Format(expected)}{options}"; - } - - private readonly struct IsNotValueConstraint( - TNumber? unexpected, - NumberTolerance options) - : IValueConstraint - where TNumber : struct, IComparable - { - public ConstraintResult IsMetBy(TNumber actual) - { - if (!options.IsWithinTolerance(actual, unexpected)) - { - return new ConstraintResult.Success(actual, ToString()); - } - - return new ConstraintResult.Failure(ToString(), $"found {Formatter.Format(actual)}"); - } - - public override string ToString() - => $"not be {Formatter.Format(unexpected)}{options}"; - } - - private readonly struct IsNotNullableValueConstraint( - TNumber? unexpected, - NumberTolerance options) - : IValueConstraint - where TNumber : struct, IComparable - { - public ConstraintResult IsMetBy(TNumber? actual) - { - if (!options.IsWithinTolerance(actual, unexpected)) - { - return new ConstraintResult.Success(actual, ToString()); - } - - return new ConstraintResult.Failure(ToString(), $"found {Formatter.Format(actual)}"); - } - - public override string ToString() - => $"not be {Formatter.Format(unexpected)}{options}"; - } } diff --git a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeFinite.cs b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeFinite.cs index d77faf4a..9ec936b0 100644 --- a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeFinite.cs +++ b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeFinite.cs @@ -16,7 +16,7 @@ public static AndOrResult> BeFinite( => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( float.PositiveInfinity, - "be finite", + _ => "be finite", (a, _) => !float.IsInfinity(a) && !float.IsNaN(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeFinite)), @@ -31,7 +31,7 @@ public static AndOrResult> BeFinite( => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( double.PositiveInfinity, - "be finite", + _ => "be finite", (a, _) => !double.IsInfinity(a) && !double.IsNaN(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeFinite)), @@ -44,9 +44,9 @@ public static AndOrResult> BeFinite( public static AndOrResult> BeFinite( this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( float.PositiveInfinity, - "be finite", + _ => "be finite", (a, _) => a != null && !float.IsInfinity(a.Value) && !float.IsNaN(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeFinite)), @@ -59,9 +59,9 @@ public static AndOrResult> BeFinite( public static AndOrResult> BeFinite( this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( double.PositiveInfinity, - "be finite", + _ => "be finite", (a, _) => a != null && !double.IsInfinity(a.Value) && !double.IsNaN(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeFinite)), @@ -76,7 +76,7 @@ public static AndOrResult> NotBeFinite( => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( float.PositiveInfinity, - "not be finite", + _ => "not be finite", (a, _) => float.IsInfinity(a) || float.IsNaN(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeFinite)), @@ -91,7 +91,7 @@ public static AndOrResult> NotBeFinite( => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( double.PositiveInfinity, - "not be finite", + _ => "not be finite", (a, _) => double.IsInfinity(a) || double.IsNaN(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeFinite)), @@ -104,9 +104,9 @@ public static AndOrResult> NotBeFinite( public static AndOrResult> NotBeFinite( this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( float.PositiveInfinity, - "not be finite", + _ => "not be finite", (a, _) => a == null || float.IsInfinity(a.Value) || float.IsNaN(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeFinite)), @@ -119,9 +119,9 @@ public static AndOrResult> NotBeFinite( public static AndOrResult> NotBeFinite( this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( double.PositiveInfinity, - "not be finite", + _ => "not be finite", (a, _) => a == null || double.IsInfinity(a.Value) || double.IsNaN(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeFinite)), diff --git a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeGreaterThan.cs b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeGreaterThan.cs new file mode 100644 index 00000000..41790792 --- /dev/null +++ b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeGreaterThan.cs @@ -0,0 +1,473 @@ +using System.Runtime.CompilerServices; +using Testably.Expectations.Core; +using Testably.Expectations.Formatting; +using Testably.Expectations.Options; +using Testably.Expectations.Results; + +// ReSharper disable once CheckNamespace +namespace Testably.Expectations; + +public static partial class ThatNumberShould +{ + /// + /// Verifies that the subject is greater than the value. + /// + public static NumberToleranceResult> BeGreaterThan( + this IThat source, + byte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NumberToleranceResult> BeGreaterThan( + this IThat source, + sbyte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NumberToleranceResult> BeGreaterThan( + this IThat source, + short? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NumberToleranceResult> BeGreaterThan( + this IThat source, + ushort? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NumberToleranceResult> BeGreaterThan( + this IThat source, + int? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NumberToleranceResult> BeGreaterThan( + this IThat source, + uint? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NumberToleranceResult> BeGreaterThan( + this IThat source, + long? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NumberToleranceResult> BeGreaterThan( + this IThat source, + ulong? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NumberToleranceResult> BeGreaterThan( + this IThat source, + float? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NumberToleranceResult> BeGreaterThan( + this IThat source, + double? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NumberToleranceResult> BeGreaterThan( + this IThat source, + decimal? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NullableNumberToleranceResult> BeGreaterThan( + this IThat source, + byte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NullableNumberToleranceResult> BeGreaterThan( + this IThat source, + sbyte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NullableNumberToleranceResult> BeGreaterThan( + this IThat source, + short? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NullableNumberToleranceResult> BeGreaterThan( + this IThat source, + ushort? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NullableNumberToleranceResult> BeGreaterThan( + this IThat source, + int? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NullableNumberToleranceResult> BeGreaterThan( + this IThat source, + uint? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NullableNumberToleranceResult> BeGreaterThan( + this IThat source, + long? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NullableNumberToleranceResult> BeGreaterThan( + this IThat source, + ulong? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NullableNumberToleranceResult> BeGreaterThan( + this IThat source, + float? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NullableNumberToleranceResult> BeGreaterThan( + this IThat source, + double? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than the value. + /// + public static NullableNumberToleranceResult> BeGreaterThan( + this IThat source, + decimal? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a > e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThan), doNotPopulateThisValue), + source, + options); + } +} diff --git a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeGreaterThanOrEqualTo.cs b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeGreaterThanOrEqualTo.cs new file mode 100644 index 00000000..2f4a14eb --- /dev/null +++ b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeGreaterThanOrEqualTo.cs @@ -0,0 +1,473 @@ +using System.Runtime.CompilerServices; +using Testably.Expectations.Core; +using Testably.Expectations.Formatting; +using Testably.Expectations.Options; +using Testably.Expectations.Results; + +// ReSharper disable once CheckNamespace +namespace Testably.Expectations; + +public static partial class ThatNumberShould +{ + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + byte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + sbyte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + short? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + ushort? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + int? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + uint? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + long? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + ulong? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + float? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + double? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + decimal? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NullableNumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + byte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NullableNumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + sbyte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NullableNumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + short? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NullableNumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + ushort? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NullableNumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + int? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NullableNumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + uint? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NullableNumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + long? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NullableNumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + ulong? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NullableNumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + float? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NullableNumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + double? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is greater than or equal to the value. + /// + public static NullableNumberToleranceResult> BeGreaterThanOrEqualTo( + this IThat source, + decimal? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a >= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be greater than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeGreaterThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } +} diff --git a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeInfinite.cs b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeInfinite.cs index 26a98b7b..b019166b 100644 --- a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeInfinite.cs +++ b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeInfinite.cs @@ -14,7 +14,7 @@ public static AndOrResult> BeInfinite(this IThat sour => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( float.PositiveInfinity, - "be infinite", + _ => "be infinite", (a, _) => float.IsInfinity(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeInfinite)), @@ -28,7 +28,7 @@ public static AndOrResult> BeInfinite( => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( double.PositiveInfinity, - "be infinite", + _ => "be infinite", (a, _) => double.IsInfinity(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeInfinite)), @@ -39,9 +39,9 @@ public static AndOrResult> BeInfinite( /// public static AndOrResult> BeInfinite(this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( float.PositiveInfinity, - "be infinite", + _ => "be infinite", (a, _) => a != null && float.IsInfinity(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeInfinite)), @@ -53,9 +53,9 @@ public static AndOrResult> BeInfinite( public static AndOrResult> BeInfinite( this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( double.PositiveInfinity, - "be infinite", + _ => "be infinite", (a, _) => a != null && double.IsInfinity(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeInfinite)), @@ -69,7 +69,7 @@ public static AndOrResult> NotBeInfinite( => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( float.PositiveInfinity, - "not be infinite", + _ => "not be infinite", (a, _) => !float.IsInfinity(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeInfinite)), @@ -83,7 +83,7 @@ public static AndOrResult> NotBeInfinite( => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( double.PositiveInfinity, - "not be infinite", + _ => "not be infinite", (a, _) => !double.IsInfinity(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeInfinite)), @@ -95,9 +95,9 @@ public static AndOrResult> NotBeInfinite( public static AndOrResult> NotBeInfinite( this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( float.PositiveInfinity, - "not be infinite", + _ => "not be infinite", (a, _) => a == null || !float.IsInfinity(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeInfinite)), @@ -110,9 +110,9 @@ public static AndOrResult> NotBeInfinite( public static AndOrResult> NotBeInfinite( this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( double.PositiveInfinity, - "not be infinite", + _ => "not be infinite", (a, _) => a == null || !double.IsInfinity(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeInfinite)), diff --git a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeLessThan.cs b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeLessThan.cs new file mode 100644 index 00000000..07e42dff --- /dev/null +++ b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeLessThan.cs @@ -0,0 +1,473 @@ +using System.Runtime.CompilerServices; +using Testably.Expectations.Core; +using Testably.Expectations.Formatting; +using Testably.Expectations.Options; +using Testably.Expectations.Results; + +// ReSharper disable once CheckNamespace +namespace Testably.Expectations; + +public static partial class ThatNumberShould +{ + /// + /// Verifies that the subject is less than the value. + /// + public static NumberToleranceResult> BeLessThan( + this IThat source, + byte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NumberToleranceResult> BeLessThan( + this IThat source, + sbyte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NumberToleranceResult> BeLessThan( + this IThat source, + short? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NumberToleranceResult> BeLessThan( + this IThat source, + ushort? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NumberToleranceResult> BeLessThan( + this IThat source, + int? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NumberToleranceResult> BeLessThan( + this IThat source, + uint? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NumberToleranceResult> BeLessThan( + this IThat source, + long? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NumberToleranceResult> BeLessThan( + this IThat source, + ulong? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NumberToleranceResult> BeLessThan( + this IThat source, + float? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NumberToleranceResult> BeLessThan( + this IThat source, + double? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NumberToleranceResult> BeLessThan( + this IThat source, + decimal? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NullableNumberToleranceResult> BeLessThan( + this IThat source, + byte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NullableNumberToleranceResult> BeLessThan( + this IThat source, + sbyte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NullableNumberToleranceResult> BeLessThan( + this IThat source, + short? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NullableNumberToleranceResult> BeLessThan( + this IThat source, + ushort? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NullableNumberToleranceResult> BeLessThan( + this IThat source, + int? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NullableNumberToleranceResult> BeLessThan( + this IThat source, + uint? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NullableNumberToleranceResult> BeLessThan( + this IThat source, + long? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NullableNumberToleranceResult> BeLessThan( + this IThat source, + ulong? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NullableNumberToleranceResult> BeLessThan( + this IThat source, + float? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NullableNumberToleranceResult> BeLessThan( + this IThat source, + double? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than the value. + /// + public static NullableNumberToleranceResult> BeLessThan( + this IThat source, + decimal? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a < e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThan), doNotPopulateThisValue), + source, + options); + } +} diff --git a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeLessThanOrEqualTo.cs b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeLessThanOrEqualTo.cs new file mode 100644 index 00000000..97e1f590 --- /dev/null +++ b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeLessThanOrEqualTo.cs @@ -0,0 +1,473 @@ +using System.Runtime.CompilerServices; +using Testably.Expectations.Core; +using Testably.Expectations.Formatting; +using Testably.Expectations.Options; +using Testably.Expectations.Results; + +// ReSharper disable once CheckNamespace +namespace Testably.Expectations; + +public static partial class ThatNumberShould +{ + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + byte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + sbyte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + short? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + ushort? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + int? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + uint? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + long? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + ulong? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + float? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + double? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + decimal? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new GenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NullableNumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + byte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NullableNumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + sbyte? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NullableNumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + short? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NullableNumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + ushort? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NullableNumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + int? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NullableNumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + uint? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NullableNumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + long? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NullableNumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + ulong? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NullableNumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + float? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NullableNumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + double? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } + + /// + /// Verifies that the subject is less than or equal to the value. + /// + public static NullableNumberToleranceResult> BeLessThanOrEqualTo( + this IThat source, + decimal? expected, + [CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") + { + NumberTolerance options = new( + (a, e, t) => a <= e - (t ?? 0)); + return new NullableNumberToleranceResult>(source.ExpectationBuilder + .AddConstraint(new NullableGenericConstraint( + expected, + e => $"be less than or equal to {Formatter.Format(e)}{options}", + (a, e) => options.IsWithinTolerance(a, e), + (a, _) => $"found {Formatter.Format(a)}")) + .AppendMethodStatement(nameof(BeLessThanOrEqualTo), doNotPopulateThisValue), + source, + options); + } +} diff --git a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeNaN.cs b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeNaN.cs index faff5cbc..5da021d9 100644 --- a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeNaN.cs +++ b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.BeNaN.cs @@ -14,7 +14,7 @@ public static AndOrResult> BeNaN(this IThat source) => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( float.NaN, - "be NaN", + _ => "be NaN", (a, _) => float.IsNaN(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeNaN)), @@ -27,7 +27,7 @@ public static AndOrResult> BeNaN(this IThat source => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( double.NaN, - "be NaN", + _ => "be NaN", (a, _) => double.IsNaN(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeNaN)), @@ -38,9 +38,9 @@ public static AndOrResult> BeNaN(this IThat source /// public static AndOrResult> BeNaN(this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( float.NaN, - "be NaN", + _ => "be NaN", (a, _) => a != null && float.IsNaN(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeNaN)), @@ -51,9 +51,9 @@ public static AndOrResult> BeNaN(this IThat source /// public static AndOrResult> BeNaN(this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( double.NaN, - "be NaN", + _ => "be NaN", (a, _) => a != null && double.IsNaN(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(BeNaN)), @@ -66,7 +66,7 @@ public static AndOrResult> NotBeNaN(this IThat source => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( float.NaN, - "not be NaN", + _ => "not be NaN", (a, _) => !float.IsNaN(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeNaN)), @@ -79,7 +79,7 @@ public static AndOrResult> NotBeNaN(this IThat sou => new(source.ExpectationBuilder .AddConstraint(new GenericConstraint( double.NaN, - "not be NaN", + _ => "not be NaN", (a, _) => !double.IsNaN(a), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeNaN)), @@ -91,9 +91,9 @@ public static AndOrResult> NotBeNaN(this IThat sou /// public static AndOrResult> NotBeNaN(this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( float.NaN, - "not be NaN", + _ => "not be NaN", (a, _) => a == null || !float.IsNaN(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeNaN)), @@ -104,9 +104,9 @@ public static AndOrResult> NotBeNaN(this IThat sou /// public static AndOrResult> NotBeNaN(this IThat source) => new(source.ExpectationBuilder - .AddConstraint(new GenericConstraint( + .AddConstraint(new NullableGenericConstraint( double.NaN, - "not be NaN", + _ => "not be NaN", (a, _) => a == null || !double.IsNaN(a.Value), (a, _) => $"found {Formatter.Format(a)}")) .AppendMethodStatement(nameof(NotBeNaN)), diff --git a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.cs b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.cs index 44b60d2c..d8b9f4db 100644 --- a/Source/Testably.Expectations/That/Numbers/ThatNumberShould.cs +++ b/Source/Testably.Expectations/That/Numbers/ThatNumberShould.cs @@ -165,11 +165,12 @@ public static IThat Should(this IExpectSubject subject) .AppendMethodStatement(nameof(Should))); private readonly struct GenericConstraint( - T expected, - string expectation, - Func condition, - Func failureMessageFactory) + T? expected, + Func expectation, + Func condition, + Func failureMessageFactory) : IValueConstraint + where T: struct { public ConstraintResult IsMetBy(T actual) { @@ -183,6 +184,28 @@ public ConstraintResult IsMetBy(T actual) } public override string ToString() - => expectation; + => expectation(expected); + } + private readonly struct NullableGenericConstraint( + T? expected, + Func expectation, + Func condition, + Func failureMessageFactory) + : IValueConstraint + where T: struct + { + public ConstraintResult IsMetBy(T? actual) + { + if (condition(actual, expected)) + { + return new ConstraintResult.Success(actual, ToString()); + } + + return new ConstraintResult.Failure(ToString(), + failureMessageFactory(actual, expected)); + } + + public override string ToString() + => expectation(expected); } } diff --git a/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_net6.0.txt b/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_net6.0.txt index 9c2fe8d4..21fa0050 100644 --- a/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_net6.0.txt +++ b/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_net6.0.txt @@ -361,10 +361,98 @@ namespace Testably.Expectations public static Testably.Expectations.Results.AndOrResult> BeFinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeFinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeFinite(this Testably.Expectations.Core.IThat source) { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } public static Testably.Expectations.Results.AndOrResult> BeNaN(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeNaN(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeNaN(this Testably.Expectations.Core.IThat source) { } diff --git a/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_net8.0.txt b/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_net8.0.txt index 9bb89488..8c241b6e 100644 --- a/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_net8.0.txt +++ b/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_net8.0.txt @@ -361,10 +361,98 @@ namespace Testably.Expectations public static Testably.Expectations.Results.AndOrResult> BeFinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeFinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeFinite(this Testably.Expectations.Core.IThat source) { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } public static Testably.Expectations.Results.AndOrResult> BeNaN(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeNaN(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeNaN(this Testably.Expectations.Core.IThat source) { } diff --git a/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_netstandard2.0.txt b/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_netstandard2.0.txt index 26ff3ba6..7ccee285 100644 --- a/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_netstandard2.0.txt +++ b/Tests/Api/Testably.Expectations.Api.Tests/Expected/Testably.Expectations_netstandard2.0.txt @@ -315,10 +315,98 @@ namespace Testably.Expectations public static Testably.Expectations.Results.AndOrResult> BeFinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeFinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeFinite(this Testably.Expectations.Core.IThat source) { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeGreaterThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeInfinite(this Testably.Expectations.Core.IThat source) { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThan(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, byte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, decimal? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, double? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, float? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, int? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, long? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, sbyte? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, short? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, uint? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ulong? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } + public static Testably.Expectations.Results.NullableNumberToleranceResult> BeLessThanOrEqualTo(this Testably.Expectations.Core.IThat source, ushort? expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string doNotPopulateThisValue = "") { } public static Testably.Expectations.Results.AndOrResult> BeNaN(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeNaN(this Testably.Expectations.Core.IThat source) { } public static Testably.Expectations.Results.AndOrResult> BeNaN(this Testably.Expectations.Core.IThat source) { } diff --git a/Tests/Api/Testably.Expectations.Api.Tests/Testably.Expectations.Api.Tests.csproj b/Tests/Api/Testably.Expectations.Api.Tests/Testably.Expectations.Api.Tests.csproj index dc24c8ee..4eaee363 100644 --- a/Tests/Api/Testably.Expectations.Api.Tests/Testably.Expectations.Api.Tests.csproj +++ b/Tests/Api/Testably.Expectations.Api.Tests/Testably.Expectations.Api.Tests.csproj @@ -8,4 +8,8 @@ + + + + diff --git a/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeGreaterThanOrEqualToTests.cs b/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeGreaterThanOrEqualToTests.cs new file mode 100644 index 00000000..777ff5a2 --- /dev/null +++ b/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeGreaterThanOrEqualToTests.cs @@ -0,0 +1,298 @@ +using System.Globalization; + +namespace Testably.Expectations.Tests.ThatTests.Numbers; + +public sealed partial class NumberShould +{ + public sealed class BeGreaterThanOrEqualToTests + { + [Theory] + [AutoData] + public async Task ShouldFailForFloatComparisonWithNull(float subject) + { + float? expected = null; + + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than or equal to , + but found {subject} + at Expect.That(subject).Should().BeGreaterThanOrEqualTo(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForIntegerComparisonWithNull(int subject) + { + int? expected = null; + + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than or equal to , + but found {subject} + at Expect.That(subject).Should().BeGreaterThanOrEqualTo(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForNullableFloatComparisonWithNull(float? subject) + { + float? expected = null; + + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than or equal to , + but found {subject} + at Expect.That(subject).Should().BeGreaterThanOrEqualTo(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForNullableIntegerComparisonWithNull(int? subject) + { + int? expected = null; + + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than or equal to , + but found {subject} + at Expect.That(subject).Should().BeGreaterThanOrEqualTo(expected) + """); + } + + [Theory] + [InlineData(1.0F, 2.1F)] + [InlineData(-3.03F, 5.8F)] + public async Task ShouldFailForSmallerFloatValues( + float subject, float expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than or equal to {expected.ToString(CultureInfo.InvariantCulture)}, + but found {subject.ToString(CultureInfo.InvariantCulture)} + at Expect.That(subject).Should().BeGreaterThanOrEqualTo(expected) + """); + } + + [Theory] + [InlineData(1, 2)] + [InlineData(-3, 5)] + public async Task ShouldFailForSmallerIntegerValues( + int subject, int expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than or equal to {expected}, + but found {subject} + at Expect.That(subject).Should().BeGreaterThanOrEqualTo(expected) + """); + } + + [Theory] + [InlineData(1.0F, 2.1F)] + [InlineData(-3.03F, 5.8F)] + public async Task ShouldFailForSmallerNullableFloatValues( + float? subject, float? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than or equal to {expected?.ToString(CultureInfo.InvariantCulture) ?? ""}, + but found {subject?.ToString(CultureInfo.InvariantCulture) ?? ""} + at Expect.That(subject).Should().BeGreaterThanOrEqualTo(expected) + """); + } + + [Theory] + [InlineData(1, 2)] + [InlineData(-3, 5)] + public async Task ShouldFailForSmallerNullableIntegerValues( + int? subject, int? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than or equal to {expected}, + but found {subject} + at Expect.That(subject).Should().BeGreaterThanOrEqualTo(expected) + """); + } + + [Theory] + [InlineData(2.0, 1.0F)] + [InlineData(0.0, 0.0F)] + public async Task ShouldSucceedForLargerOrEqualDoubleAndFloatValues(double subject, + float expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2.0F, 1.0F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldSucceedForLargerOrEqualFloatValueAndNullableValue(float subject, + float? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2.0F, 1.0F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldSucceedForLargerOrEqualFloatValues(float subject, float expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2, 1)] + [InlineData(0, 0)] + public async Task ShouldSucceedForLargerOrEqualIntegerValueAndNullableValue(int subject, + int? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2, 1)] + [InlineData(0, 0)] + public async Task ShouldSucceedForLargerOrEqualIntegerValues(int subject, int expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2L, 1)] + [InlineData(0L, 0)] + public async Task ShouldSucceedForLargerOrEqualLongAndIntegerValues(long subject, + int expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2.0, 1.0F)] + [InlineData(0.0, 0.0F)] + public async Task ShouldSucceedForLargerOrEqualNullableDoubleAndNullableFloatValues( + double? subject, float? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2.0F, 1.0F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldSucceedForLargerOrEqualNullableFloatValueAndExpectedValue( + float? subject, + float expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2.0F, 1.0F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldSucceedForLargerOrEqualNullableFloatValues(float? subject, + float? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2, 1)] + [InlineData(0, 0)] + public async Task ShouldSucceedForLargerOrEqualNullableIntegerValueAndExpectedValue( + int? subject, + int expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2, 1)] + [InlineData(0, 0)] + public async Task ShouldSucceedForLargerOrEqualNullableIntegerValues(int? subject, + int? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2L, 1)] + [InlineData(0L, 0)] + public async Task ShouldSucceedForLargerOrEqualNullableLongAndNullableIntegerValues( + long? subject, + int? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + } +} diff --git a/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeGreaterThanTests.cs b/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeGreaterThanTests.cs new file mode 100644 index 00000000..e5e80fa7 --- /dev/null +++ b/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeGreaterThanTests.cs @@ -0,0 +1,283 @@ +using System.Globalization; + +namespace Testably.Expectations.Tests.ThatTests.Numbers; + +public sealed partial class NumberShould +{ + public sealed class BeGreaterThanTests + { + [Theory] + [AutoData] + public async Task ShouldFailForFloatComparisonWithNull(float subject) + { + float? expected = null; + + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than , + but found {subject} + at Expect.That(subject).Should().BeGreaterThan(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForIntegerComparisonWithNull(int subject) + { + int? expected = null; + + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than , + but found {subject} + at Expect.That(subject).Should().BeGreaterThan(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForNullableFloatComparisonWithNull(float? subject) + { + float? expected = null; + + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than , + but found {subject} + at Expect.That(subject).Should().BeGreaterThan(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForNullableIntegerComparisonWithNull(int? subject) + { + int? expected = null; + + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than , + but found {subject} + at Expect.That(subject).Should().BeGreaterThan(expected) + """); + } + + [Theory] + [InlineData(1.0F, 2.1F)] + [InlineData(-3.03F, 5.8F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldFailForSmallerOrEqualFloatValues( + float subject, float expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than {expected.ToString(CultureInfo.InvariantCulture)}, + but found {subject.ToString(CultureInfo.InvariantCulture)} + at Expect.That(subject).Should().BeGreaterThan(expected) + """); + } + + [Theory] + [InlineData(1, 2)] + [InlineData(-3, 5)] + [InlineData(0, 0)] + public async Task ShouldFailForSmallerOrEqualIntegerValues( + int subject, int expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than {expected}, + but found {subject} + at Expect.That(subject).Should().BeGreaterThan(expected) + """); + } + + [Theory] + [InlineData(1.0F, 2.1F)] + [InlineData(-3.03F, 5.8F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldFailForSmallerOrEqualNullableFloatValues( + float? subject, float? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than {expected?.ToString(CultureInfo.InvariantCulture) ?? ""}, + but found {subject?.ToString(CultureInfo.InvariantCulture) ?? ""} + at Expect.That(subject).Should().BeGreaterThan(expected) + """); + } + + [Theory] + [InlineData(1, 2)] + [InlineData(-3, 5)] + [InlineData(0, 0)] + public async Task ShouldFailForSmallerOrEqualNullableIntegerValues( + int? subject, int? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be greater than {expected}, + but found {subject} + at Expect.That(subject).Should().BeGreaterThan(expected) + """); + } + + [Theory] + [InlineData(2.0, 1.0F)] + public async Task ShouldSucceedForLargerDoubleAndFloatValues(double subject, float expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2.0F, 1.0F)] + public async Task ShouldSucceedForLargerFloatValueAndNullableValue(float subject, + float? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2.0F, 1.0F)] + public async Task ShouldSucceedForLargerFloatValues(float subject, float expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2, 1)] + public async Task ShouldSucceedForLargerIntegerValueAndNullableValue(int subject, + int? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2, 1)] + public async Task ShouldSucceedForLargerIntegerValues(int subject, int expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2L, 1)] + public async Task ShouldSucceedForLargerLongAndIntegerValues(long subject, int expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2.0, 1.0F)] + public async Task ShouldSucceedForLargerNullableDoubleAndNullableFloatValues( + double? subject, float? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2.0F, 1.0F)] + public async Task ShouldSucceedForLargerNullableFloatValueAndExpectedValue(float? subject, + float expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2.0F, 1.0F)] + public async Task ShouldSucceedForLargerNullableFloatValues(float? subject, float? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2, 1)] + public async Task ShouldSucceedForLargerNullableIntegerValueAndExpectedValue(int? subject, + int expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2, 1)] + public async Task ShouldSucceedForLargerNullableIntegerValues(int? subject, int? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(2L, 1)] + public async Task ShouldSucceedForLargerNullableLongAndNullableIntegerValues(long? subject, + int? expected) + { + async Task Act() + => await That(subject).Should().BeGreaterThan(expected); + + await That(Act).Should().NotThrow(); + } + } +} diff --git a/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeLessThanOrEqualToTests.cs b/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeLessThanOrEqualToTests.cs new file mode 100644 index 00000000..e880fe53 --- /dev/null +++ b/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeLessThanOrEqualToTests.cs @@ -0,0 +1,298 @@ +using System.Globalization; + +namespace Testably.Expectations.Tests.ThatTests.Numbers; + +public sealed partial class NumberShould +{ + public sealed class BeLessThanOrEqualToTests + { + [Theory] + [AutoData] + public async Task ShouldFailForFloatComparisonWithNull(float subject) + { + float? expected = null; + + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than or equal to , + but found {subject} + at Expect.That(subject).Should().BeLessThanOrEqualTo(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForIntegerComparisonWithNull(int subject) + { + int? expected = null; + + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than or equal to , + but found {subject} + at Expect.That(subject).Should().BeLessThanOrEqualTo(expected) + """); + } + + [Theory] + [InlineData(2.1F, 1.0F)] + [InlineData(5.8F, -3.03F)] + public async Task ShouldFailForLargerFloatValues( + float subject, float expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than or equal to {expected.ToString(CultureInfo.InvariantCulture)}, + but found {subject.ToString(CultureInfo.InvariantCulture)} + at Expect.That(subject).Should().BeLessThanOrEqualTo(expected) + """); + } + + [Theory] + [InlineData(2, 1)] + [InlineData(5, -3)] + public async Task ShouldFailForLargerIntegerValues( + int subject, int expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than or equal to {expected}, + but found {subject} + at Expect.That(subject).Should().BeLessThanOrEqualTo(expected) + """); + } + + [Theory] + [InlineData(2.1F, 1.0F)] + [InlineData(5.8F, -3.03F)] + public async Task ShouldFailForLargerNullableFloatValues( + float? subject, float? expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than or equal to {expected?.ToString(CultureInfo.InvariantCulture) ?? ""}, + but found {subject?.ToString(CultureInfo.InvariantCulture) ?? ""} + at Expect.That(subject).Should().BeLessThanOrEqualTo(expected) + """); + } + + [Theory] + [InlineData(2, 1)] + [InlineData(5, -3)] + public async Task ShouldFailForLargerNullableIntegerValues( + int? subject, int? expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than or equal to {expected}, + but found {subject} + at Expect.That(subject).Should().BeLessThanOrEqualTo(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForNullableFloatComparisonWithNull(float? subject) + { + float? expected = null; + + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than or equal to , + but found {subject} + at Expect.That(subject).Should().BeLessThanOrEqualTo(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForNullableIntegerComparisonWithNull(int? subject) + { + int? expected = null; + + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than or equal to , + but found {subject} + at Expect.That(subject).Should().BeLessThanOrEqualTo(expected) + """); + } + + [Theory] + [InlineData(1.0, 2.0F)] + [InlineData(0.0, 0.0F)] + public async Task ShouldSucceedForSmallerOrEqualDoubleAndFloatValues(double subject, + float expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1.0F, 2.0F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldSucceedForSmallerOrEqualFloatValueAndNullableValue(float subject, + float? expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1.0F, 2.0F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldSucceedForSmallerOrEqualFloatValues(float subject, float expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1, 2)] + [InlineData(0, 0)] + public async Task ShouldSucceedForSmallerOrEqualIntegerValueAndNullableValue(int subject, + int? expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1, 2)] + [InlineData(0, 0)] + public async Task ShouldSucceedForSmallerOrEqualIntegerValues(int subject, int expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1L, 2)] + [InlineData(0L, 0)] + public async Task ShouldSucceedForSmallerOrEqualLongAndIntegerValues(long subject, + int expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1.0, 2.0F)] + [InlineData(0.0, 0.0F)] + public async Task ShouldSucceedForSmallerOrEqualNullableDoubleAndNullableFloatValues( + double? subject, float? expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1.0F, 2.0F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldSucceedForSmallerOrEqualNullableFloatValueAndExpectedValue( + float? subject, + float expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1.0F, 2.0F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldSucceedForSmallerOrEqualNullableFloatValues(float? subject, + float? expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1, 2)] + [InlineData(0, 0)] + public async Task ShouldSucceedForSmallerOrEqualNullableIntegerValueAndExpectedValue( + int? subject, + int expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1, 2)] + [InlineData(0, 0)] + public async Task ShouldSucceedForSmallerOrEqualNullableIntegerValues(int? subject, + int? expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1L, 2)] + [InlineData(0L, 0)] + public async Task ShouldSucceedForSmallerOrEqualNullableLongAndNullableIntegerValues( + long? subject, + int? expected) + { + async Task Act() + => await That(subject).Should().BeLessThanOrEqualTo(expected); + + await That(Act).Should().NotThrow(); + } + } +} diff --git a/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeLessThanTests.cs b/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeLessThanTests.cs new file mode 100644 index 00000000..9766ca0e --- /dev/null +++ b/Tests/Testably.Expectations.Tests/ThatTests/Numbers/NumberShould.BeLessThanTests.cs @@ -0,0 +1,283 @@ +using System.Globalization; + +namespace Testably.Expectations.Tests.ThatTests.Numbers; + +public sealed partial class NumberShould +{ + public sealed class BeLessThanTests + { + [Theory] + [AutoData] + public async Task ShouldFailForFloatComparisonWithNull(float subject) + { + float? expected = null; + + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than , + but found {subject} + at Expect.That(subject).Should().BeLessThan(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForIntegerComparisonWithNull(int subject) + { + int? expected = null; + + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than , + but found {subject} + at Expect.That(subject).Should().BeLessThan(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForNullableFloatComparisonWithNull(float? subject) + { + float? expected = null; + + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than , + but found {subject} + at Expect.That(subject).Should().BeLessThan(expected) + """); + } + + [Theory] + [AutoData] + public async Task ShouldFailForNullableIntegerComparisonWithNull(int? subject) + { + int? expected = null; + + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than , + but found {subject} + at Expect.That(subject).Should().BeLessThan(expected) + """); + } + + [Theory] + [InlineData(2.1F, 1.0F)] + [InlineData(5.8F, -3.03F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldFailForLargerOrEqualFloatValues( + float subject, float expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than {expected.ToString(CultureInfo.InvariantCulture)}, + but found {subject.ToString(CultureInfo.InvariantCulture)} + at Expect.That(subject).Should().BeLessThan(expected) + """); + } + + [Theory] + [InlineData(2, 1)] + [InlineData(5, -3)] + [InlineData(0, 0)] + public async Task ShouldFailForLargerOrEqualIntegerValues( + int subject, int expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than {expected}, + but found {subject} + at Expect.That(subject).Should().BeLessThan(expected) + """); + } + + [Theory] + [InlineData(2.1F, 1.0F)] + [InlineData(5.8F, -3.03F)] + [InlineData(0.0F, 0.0F)] + public async Task ShouldFailForLargerOrEqualNullableFloatValues( + float? subject, float? expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than {expected?.ToString(CultureInfo.InvariantCulture) ?? ""}, + but found {subject?.ToString(CultureInfo.InvariantCulture) ?? ""} + at Expect.That(subject).Should().BeLessThan(expected) + """); + } + + [Theory] + [InlineData(2, 1)] + [InlineData(5, -3)] + [InlineData(0, 0)] + public async Task ShouldFailForLargerOrEqualNullableIntegerValues( + int? subject, int? expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().Throw() + .WithMessage($""" + Expected subject to + be less than {expected}, + but found {subject} + at Expect.That(subject).Should().BeLessThan(expected) + """); + } + + [Theory] + [InlineData(1.0, 2.0F)] + public async Task ShouldSucceedForSmallerDoubleAndFloatValues(double subject, float expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1.0F, 2.0F)] + public async Task ShouldSucceedForSmallerFloatValueAndNullableValue(float subject, + float? expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1.0F, 2.0F)] + public async Task ShouldSucceedForSmallerFloatValues(float subject, float expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1, 2)] + public async Task ShouldSucceedForSmallerIntegerValueAndNullableValue(int subject, + int? expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1, 2)] + public async Task ShouldSucceedForSmallerIntegerValues(int subject, int expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1L, 2)] + public async Task ShouldSucceedForSmallerLongAndIntegerValues(long subject, int expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1.0, 2.0F)] + public async Task ShouldSucceedForSmallerNullableDoubleAndNullableFloatValues( + double? subject, float? expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1.0F, 2.0F)] + public async Task ShouldSucceedForSmallerNullableFloatValueAndExpectedValue(float? subject, + float expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1.0F, 2.0F)] + public async Task ShouldSucceedForSmallerNullableFloatValues(float? subject, float? expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1, 2)] + public async Task ShouldSucceedForSmallerNullableIntegerValueAndExpectedValue(int? subject, + int expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1, 2)] + public async Task ShouldSucceedForSmallerNullableIntegerValues(int? subject, int? expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + + [Theory] + [InlineData(1L, 2)] + public async Task ShouldSucceedForSmallerNullableLongAndNullableIntegerValues(long? subject, + int? expected) + { + async Task Act() + => await That(subject).Should().BeLessThan(expected); + + await That(Act).Should().NotThrow(); + } + } +}