Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
266 changes: 265 additions & 1 deletion Source/aweXpect/That/Numbers/ThatNumber.IsBetween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static partial class ThatNumber
{
#if NET8_0_OR_GREATER
/// <summary>
/// Verifies that the subject is between <paramref name="minimum" />…
/// Verifies that the subject is between the <paramref name="minimum" />…
Comment thread
vbreuss marked this conversation as resolved.
/// </summary>
public static BetweenResult<AndOrResult<TNumber, IThat<TNumber>>, TNumber?> IsBetween<TNumber>(
this IThat<TNumber> source, TNumber? minimum)
Expand All @@ -32,6 +32,28 @@ public static partial class ThatNumber
source.Get().ExpectationBuilder.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<TNumber>(it, grammars, minimum, maximum)),
source));

/// <summary>
/// Verifies that the subject is not between the <paramref name="minimum" />…
Comment thread
vbreuss marked this conversation as resolved.
/// </summary>
public static BetweenResult<AndOrResult<TNumber, IThat<TNumber>>, TNumber?> IsNotBetween<TNumber>(
this IThat<TNumber> source, TNumber? minimum)
where TNumber : struct, INumber<TNumber>
=> new(maximum => new AndOrResult<TNumber, IThat<TNumber>>(
source.Get().ExpectationBuilder.AddConstraint((it, grammars) =>
new IsInRangeConstraint<TNumber>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<TNumber?, IThat<TNumber?>>, TNumber?> IsNotBetween<TNumber>(
this IThat<TNumber?> source, TNumber? minimum)
where TNumber : struct, INumber<TNumber>
=> new(maximum => new AndOrResult<TNumber?, IThat<TNumber?>>(
source.Get().ExpectationBuilder.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<TNumber>(it, grammars, minimum, maximum).Invert()),
source));

private sealed class IsInRangeConstraint<TNumber> : ConstraintResult.WithValue<TNumber>,
IValueConstraint<TNumber>
Expand Down Expand Up @@ -395,6 +417,248 @@ protected override void AppendNegatedResult(StringBuilder stringBuilder, string?
new NullableIsInRangeConstraint<decimal>(it, grammars, minimum, maximum)),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<byte, IThat<byte>>, byte?> IsNotBetween(
this IThat<byte> source,
byte? minimum)
=> new(maximum => new AndOrResult<byte, IThat<byte>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new IsInRangeConstraint<byte>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<sbyte, IThat<sbyte>>, sbyte?> IsNotBetween(
this IThat<sbyte> source,
sbyte? minimum)
=> new(maximum => new AndOrResult<sbyte, IThat<sbyte>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new IsInRangeConstraint<sbyte>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<short, IThat<short>>, short?> IsNotBetween(
this IThat<short> source,
short? minimum)
=> new(maximum => new AndOrResult<short, IThat<short>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new IsInRangeConstraint<short>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<ushort, IThat<ushort>>, ushort?> IsNotBetween(
this IThat<ushort> source,
ushort? minimum)
=> new(maximum => new AndOrResult<ushort, IThat<ushort>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new IsInRangeConstraint<ushort>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<int, IThat<int>>, int?> IsNotBetween(
this IThat<int> source,
int? minimum)
=> new(maximum => new AndOrResult<int, IThat<int>>(source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=>
new IsInRangeConstraint<int>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<uint, IThat<uint>>, uint?> IsNotBetween(
this IThat<uint> source,
uint? minimum)
=> new(maximum => new AndOrResult<uint, IThat<uint>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new IsInRangeConstraint<uint>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<long, IThat<long>>, long?> IsNotBetween(
this IThat<long> source,
long? minimum)
=> new(maximum => new AndOrResult<long, IThat<long>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new IsInRangeConstraint<long>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<ulong, IThat<ulong>>, ulong?> IsNotBetween(
this IThat<ulong> source,
ulong? minimum)
=> new(maximum => new AndOrResult<ulong, IThat<ulong>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new IsInRangeConstraint<ulong>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<float, IThat<float>>, float?> IsNotBetween(
this IThat<float> source,
float? minimum)
=> new(maximum => new AndOrResult<float, IThat<float>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new IsInRangeConstraint<float>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<double, IThat<double>>, double?> IsNotBetween(
this IThat<double> source,
double? minimum)
=> new(maximum => new AndOrResult<double, IThat<double>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new IsInRangeConstraint<double>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<decimal, IThat<decimal>>, decimal?> IsNotBetween(
this IThat<decimal> source,
decimal? minimum)
=> new(maximum => new AndOrResult<decimal, IThat<decimal>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new IsInRangeConstraint<decimal>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<byte?, IThat<byte?>>, byte?> IsNotBetween(
this IThat<byte?> source,
byte? minimum)
=> new(maximum => new AndOrResult<byte?, IThat<byte?>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<byte>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<sbyte?, IThat<sbyte?>>, sbyte?> IsNotBetween(
this IThat<sbyte?> source,
sbyte? minimum)
=> new(maximum => new AndOrResult<sbyte?, IThat<sbyte?>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<sbyte>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<short?, IThat<short?>>, short?> IsNotBetween(
this IThat<short?> source,
short? minimum)
=> new(maximum => new AndOrResult<short?, IThat<short?>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<short>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<ushort?, IThat<ushort?>>, ushort?> IsNotBetween(
this IThat<ushort?> source,
ushort? minimum)
=> new(maximum => new AndOrResult<ushort?, IThat<ushort?>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<ushort>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<int?, IThat<int?>>, int?> IsNotBetween(
this IThat<int?> source,
int? minimum)
=> new(maximum => new AndOrResult<int?, IThat<int?>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<int>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<uint?, IThat<uint?>>, uint?> IsNotBetween(
this IThat<uint?> source,
uint? minimum)
=> new(maximum => new AndOrResult<uint?, IThat<uint?>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<uint>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<long?, IThat<long?>>, long?> IsNotBetween(
this IThat<long?> source,
long? minimum)
=> new(maximum => new AndOrResult<long?, IThat<long?>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<long>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<ulong?, IThat<ulong?>>, ulong?> IsNotBetween(
this IThat<ulong?> source,
ulong? minimum)
=> new(maximum => new AndOrResult<ulong?, IThat<ulong?>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<ulong>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<float?, IThat<float?>>, float?> IsNotBetween(
this IThat<float?> source,
float? minimum)
=> new(maximum => new AndOrResult<float?, IThat<float?>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<float>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<double?, IThat<double?>>, double?> IsNotBetween(
this IThat<double?> source,
double? minimum)
=> new(maximum => new AndOrResult<double?, IThat<double?>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<double>(it, grammars, minimum, maximum).Invert()),
source));

/// <summary>
/// Verifies that the subject is not in the range between the <paramref name="minimum" />…
/// </summary>
public static BetweenResult<AndOrResult<decimal?, IThat<decimal?>>, decimal?> IsNotBetween(
this IThat<decimal?> source,
decimal? minimum)
=> new(maximum => new AndOrResult<decimal?, IThat<decimal?>>(source.Get().ExpectationBuilder
.AddConstraint((it, grammars) =>
new NullableIsInRangeConstraint<decimal>(it, grammars, minimum, maximum).Invert()),
source));

private sealed class IsInRangeConstraint<TNumber> : ConstraintResult.WithValue<TNumber>,
IValueConstraint<TNumber>
where TNumber : struct, IComparable<TNumber>
Expand Down
4 changes: 4 additions & 0 deletions Tests/aweXpect.Api.Tests/Expected/aweXpect_net8.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,10 @@ namespace aweXpect
where TNumber : struct, System.Numerics.INumber<TNumber> { }
public static aweXpect.Results.AndOrResult<TNumber?, aweXpect.Core.IThat<TNumber?>> IsNegative<TNumber>(this aweXpect.Core.IThat<TNumber?> source)
where TNumber : struct, System.Numerics.INumber<TNumber> { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<TNumber, aweXpect.Core.IThat<TNumber>>, TNumber?> IsNotBetween<TNumber>(this aweXpect.Core.IThat<TNumber> source, TNumber? minimum)
where TNumber : struct, System.Numerics.INumber<TNumber> { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<TNumber?, aweXpect.Core.IThat<TNumber?>>, TNumber?> IsNotBetween<TNumber>(this aweXpect.Core.IThat<TNumber?> source, TNumber? minimum)
where TNumber : struct, System.Numerics.INumber<TNumber> { }
public static aweXpect.Results.NumberToleranceResult<TNumber, aweXpect.Core.IThat<TNumber>> IsNotEqualTo<TNumber>(this aweXpect.Core.IThat<TNumber> source, TNumber? unexpected)
where TNumber : struct, System.Numerics.INumber<TNumber> { }
public static aweXpect.Results.NullableNumberToleranceResult<TNumber, aweXpect.Core.IThat<TNumber?>> IsNotEqualTo<TNumber>(this aweXpect.Core.IThat<TNumber?> source, TNumber? unexpected)
Expand Down
22 changes: 22 additions & 0 deletions Tests/aweXpect.Api.Tests/Expected/aweXpect_netstandard2.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,28 @@ namespace aweXpect
public static aweXpect.Results.AndOrResult<sbyte?, aweXpect.Core.IThat<sbyte?>> IsNegative(this aweXpect.Core.IThat<sbyte?> source) { }
public static aweXpect.Results.AndOrResult<short, aweXpect.Core.IThat<short>> IsNegative(this aweXpect.Core.IThat<short> source) { }
public static aweXpect.Results.AndOrResult<short?, aweXpect.Core.IThat<short?>> IsNegative(this aweXpect.Core.IThat<short?> source) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<byte, aweXpect.Core.IThat<byte>>, byte?> IsNotBetween(this aweXpect.Core.IThat<byte> source, byte? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<byte?, aweXpect.Core.IThat<byte?>>, byte?> IsNotBetween(this aweXpect.Core.IThat<byte?> source, byte? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<decimal, aweXpect.Core.IThat<decimal>>, decimal?> IsNotBetween(this aweXpect.Core.IThat<decimal> source, decimal? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<decimal?, aweXpect.Core.IThat<decimal?>>, decimal?> IsNotBetween(this aweXpect.Core.IThat<decimal?> source, decimal? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<double, aweXpect.Core.IThat<double>>, double?> IsNotBetween(this aweXpect.Core.IThat<double> source, double? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<double?, aweXpect.Core.IThat<double?>>, double?> IsNotBetween(this aweXpect.Core.IThat<double?> source, double? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<float, aweXpect.Core.IThat<float>>, float?> IsNotBetween(this aweXpect.Core.IThat<float> source, float? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<float?, aweXpect.Core.IThat<float?>>, float?> IsNotBetween(this aweXpect.Core.IThat<float?> source, float? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<int, aweXpect.Core.IThat<int>>, int?> IsNotBetween(this aweXpect.Core.IThat<int> source, int? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<int?, aweXpect.Core.IThat<int?>>, int?> IsNotBetween(this aweXpect.Core.IThat<int?> source, int? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<long, aweXpect.Core.IThat<long>>, long?> IsNotBetween(this aweXpect.Core.IThat<long> source, long? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<long?, aweXpect.Core.IThat<long?>>, long?> IsNotBetween(this aweXpect.Core.IThat<long?> source, long? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<sbyte, aweXpect.Core.IThat<sbyte>>, sbyte?> IsNotBetween(this aweXpect.Core.IThat<sbyte> source, sbyte? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<sbyte?, aweXpect.Core.IThat<sbyte?>>, sbyte?> IsNotBetween(this aweXpect.Core.IThat<sbyte?> source, sbyte? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<short, aweXpect.Core.IThat<short>>, short?> IsNotBetween(this aweXpect.Core.IThat<short> source, short? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<short?, aweXpect.Core.IThat<short?>>, short?> IsNotBetween(this aweXpect.Core.IThat<short?> source, short? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<uint, aweXpect.Core.IThat<uint>>, uint?> IsNotBetween(this aweXpect.Core.IThat<uint> source, uint? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<uint?, aweXpect.Core.IThat<uint?>>, uint?> IsNotBetween(this aweXpect.Core.IThat<uint?> source, uint? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<ulong, aweXpect.Core.IThat<ulong>>, ulong?> IsNotBetween(this aweXpect.Core.IThat<ulong> source, ulong? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<ulong?, aweXpect.Core.IThat<ulong?>>, ulong?> IsNotBetween(this aweXpect.Core.IThat<ulong?> source, ulong? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<ushort, aweXpect.Core.IThat<ushort>>, ushort?> IsNotBetween(this aweXpect.Core.IThat<ushort> source, ushort? minimum) { }
public static aweXpect.Results.BetweenResult<aweXpect.Results.AndOrResult<ushort?, aweXpect.Core.IThat<ushort?>>, ushort?> IsNotBetween(this aweXpect.Core.IThat<ushort?> source, ushort? minimum) { }
public static aweXpect.Results.NumberToleranceResult<byte, aweXpect.Core.IThat<byte>> IsNotEqualTo(this aweXpect.Core.IThat<byte> source, byte? unexpected) { }
public static aweXpect.Results.NullableNumberToleranceResult<byte, aweXpect.Core.IThat<byte?>> IsNotEqualTo(this aweXpect.Core.IThat<byte?> source, byte? unexpected) { }
public static aweXpect.Results.NumberToleranceResult<decimal, aweXpect.Core.IThat<decimal>> IsNotEqualTo(this aweXpect.Core.IThat<decimal> source, decimal? unexpected) { }
Expand Down
Loading
Loading