Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add difference to numeric assertion failure messages #1859

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 20 additions & 20 deletions Src/FluentAssertions/AssertionExtensions.cs
Expand Up @@ -496,7 +496,7 @@ public static ComparableTypeAssertions<T> Should<T>(this IComparable<T> comparab
[Pure]
public static NumericAssertions<int> Should(this int actualValue)
{
return new NumericAssertions<int>(actualValue);
return new IntAssertions(actualValue);
}

/// <summary>
Expand All @@ -506,7 +506,7 @@ public static NumericAssertions<int> Should(this int actualValue)
[Pure]
public static NullableNumericAssertions<int> Should(this int? actualValue)
{
return new NullableNumericAssertions<int>(actualValue);
return new NullableIntAssertions(actualValue);
}

/// <summary>
Expand All @@ -516,7 +516,7 @@ public static NullableNumericAssertions<int> Should(this int? actualValue)
[Pure]
public static NumericAssertions<uint> Should(this uint actualValue)
{
return new NumericAssertions<uint>(actualValue);
return new UIntAssertions(actualValue);
}

/// <summary>
Expand All @@ -526,7 +526,7 @@ public static NumericAssertions<uint> Should(this uint actualValue)
[Pure]
public static NullableNumericAssertions<uint> Should(this uint? actualValue)
{
return new NullableNumericAssertions<uint>(actualValue);
return new NullableUIntAssertions(actualValue);
}

/// <summary>
Expand All @@ -536,7 +536,7 @@ public static NullableNumericAssertions<uint> Should(this uint? actualValue)
[Pure]
public static NumericAssertions<decimal> Should(this decimal actualValue)
{
return new NumericAssertions<decimal>(actualValue);
return new DecimalAssertions(actualValue);
}

/// <summary>
Expand All @@ -546,7 +546,7 @@ public static NumericAssertions<decimal> Should(this decimal actualValue)
[Pure]
public static NullableNumericAssertions<decimal> Should(this decimal? actualValue)
{
return new NullableNumericAssertions<decimal>(actualValue);
return new NullableDecimalAssertions(actualValue);
}

/// <summary>
Expand All @@ -556,7 +556,7 @@ public static NullableNumericAssertions<decimal> Should(this decimal? actualValu
[Pure]
public static NumericAssertions<byte> Should(this byte actualValue)
{
return new NumericAssertions<byte>(actualValue);
return new ByteAssertions(actualValue);
}

/// <summary>
Expand All @@ -566,7 +566,7 @@ public static NumericAssertions<byte> Should(this byte actualValue)
[Pure]
public static NullableNumericAssertions<byte> Should(this byte? actualValue)
{
return new NullableNumericAssertions<byte>(actualValue);
return new NullableByteAssertions(actualValue);
}

/// <summary>
Expand All @@ -576,7 +576,7 @@ public static NullableNumericAssertions<byte> Should(this byte? actualValue)
[Pure]
public static NumericAssertions<sbyte> Should(this sbyte actualValue)
{
return new NumericAssertions<sbyte>(actualValue);
return new SByteAssertions(actualValue);
}

/// <summary>
Expand All @@ -586,7 +586,7 @@ public static NumericAssertions<sbyte> Should(this sbyte actualValue)
[Pure]
public static NullableNumericAssertions<sbyte> Should(this sbyte? actualValue)
{
return new NullableNumericAssertions<sbyte>(actualValue);
return new NullableSByteAssertions(actualValue);
}

/// <summary>
Expand All @@ -596,7 +596,7 @@ public static NullableNumericAssertions<sbyte> Should(this sbyte? actualValue)
[Pure]
public static NumericAssertions<short> Should(this short actualValue)
{
return new NumericAssertions<short>(actualValue);
return new ShortAssertions(actualValue);
}

/// <summary>
Expand All @@ -606,7 +606,7 @@ public static NumericAssertions<short> Should(this short actualValue)
[Pure]
public static NullableNumericAssertions<short> Should(this short? actualValue)
{
return new NullableNumericAssertions<short>(actualValue);
return new NullableShortAssertions(actualValue);
}

/// <summary>
Expand All @@ -616,7 +616,7 @@ public static NullableNumericAssertions<short> Should(this short? actualValue)
[Pure]
public static NumericAssertions<ushort> Should(this ushort actualValue)
{
return new NumericAssertions<ushort>(actualValue);
return new UShortAssertions(actualValue);
}

/// <summary>
Expand All @@ -626,7 +626,7 @@ public static NumericAssertions<ushort> Should(this ushort actualValue)
[Pure]
public static NullableNumericAssertions<ushort> Should(this ushort? actualValue)
{
return new NullableNumericAssertions<ushort>(actualValue);
return new NullableUShortAssertions(actualValue);
}

/// <summary>
Expand All @@ -636,7 +636,7 @@ public static NullableNumericAssertions<ushort> Should(this ushort? actualValue)
[Pure]
public static NumericAssertions<long> Should(this long actualValue)
{
return new NumericAssertions<long>(actualValue);
return new LongAssertions(actualValue);
}

/// <summary>
Expand All @@ -646,7 +646,7 @@ public static NumericAssertions<long> Should(this long actualValue)
[Pure]
public static NullableNumericAssertions<long> Should(this long? actualValue)
{
return new NullableNumericAssertions<long>(actualValue);
return new NullableLongAssertions(actualValue);
}

/// <summary>
Expand All @@ -656,7 +656,7 @@ public static NullableNumericAssertions<long> Should(this long? actualValue)
[Pure]
public static NumericAssertions<ulong> Should(this ulong actualValue)
{
return new NumericAssertions<ulong>(actualValue);
return new ULongAssertions(actualValue);
}

/// <summary>
Expand All @@ -666,7 +666,7 @@ public static NumericAssertions<ulong> Should(this ulong actualValue)
[Pure]
public static NullableNumericAssertions<ulong> Should(this ulong? actualValue)
{
return new NullableNumericAssertions<ulong>(actualValue);
return new NullableULongAssertions(actualValue);
}

/// <summary>
Expand All @@ -686,7 +686,7 @@ public static NumericAssertions<float> Should(this float actualValue)
[Pure]
public static NullableNumericAssertions<float> Should(this float? actualValue)
{
return new NullableNumericAssertions<float>(actualValue);
return new NullableFloatAssertions(actualValue);
}

/// <summary>
Expand All @@ -706,7 +706,7 @@ public static NumericAssertions<double> Should(this double actualValue)
[Pure]
public static NullableNumericAssertions<double> Should(this double? actualValue)
{
return new NullableNumericAssertions<double>(actualValue);
return new NullableDoubleAssertions(actualValue);
}

/// <summary>
Expand Down
18 changes: 18 additions & 0 deletions Src/FluentAssertions/Numeric/ByteAssertions.cs
@@ -0,0 +1,18 @@
using System.Diagnostics;

namespace FluentAssertions.Numeric
{
/// <summary>
/// Contains a number of methods to assert that a <see cref="byte"/> is in the expected state.
/// </summary>
[DebuggerNonUserCode]
public class ByteAssertions : NumericAssertions<byte>
{
public ByteAssertions(byte value)
: base(value)
{
}

private protected override byte? CalculateDifference(byte? actual, byte expected) => (byte?)(actual - expected);
}
}
18 changes: 18 additions & 0 deletions Src/FluentAssertions/Numeric/DecimalAssertions.cs
@@ -0,0 +1,18 @@
using System.Diagnostics;

namespace FluentAssertions.Numeric
{
/// <summary>
/// Contains a number of methods to assert that a <see cref="decimal"/> is in the expected state.
/// </summary>
[DebuggerNonUserCode]
public class DecimalAssertions : NumericAssertions<decimal>
{
public DecimalAssertions(decimal value)
: base(value)
{
}

private protected override decimal? CalculateDifference(decimal? actual, decimal expected) => actual - expected;
}
}
14 changes: 11 additions & 3 deletions Src/FluentAssertions/Numeric/DoubleAssertions.cs
@@ -1,12 +1,20 @@
namespace FluentAssertions.Numeric
using System.Diagnostics;

namespace FluentAssertions.Numeric
{
internal class DoubleAssertions : NumericAssertions<double>
/// <summary>
/// Contains a number of methods to assert that a <see cref="double"/> is in the expected state.
/// </summary>
[DebuggerNonUserCode]
public class DoubleAssertions : NumericAssertions<double>
{
public DoubleAssertions(double value)
public DoubleAssertions(double value)
: base(value)
{
}

private protected override bool IsNaN(double value) => double.IsNaN(value);

private protected override double? CalculateDifference(double? actual, double expected) => actual - expected;
}
}
12 changes: 10 additions & 2 deletions Src/FluentAssertions/Numeric/FloatAssertions.cs
@@ -1,12 +1,20 @@
namespace FluentAssertions.Numeric
using System.Diagnostics;

namespace FluentAssertions.Numeric
{
internal class FloatAssertions : NumericAssertions<float>
/// <summary>
/// Contains a number of methods to assert that a <see cref="float"/> is in the expected state.
/// </summary>
[DebuggerNonUserCode]
public class FloatAssertions : NumericAssertions<float>
{
public FloatAssertions(float value)
: base(value)
{
}

private protected override bool IsNaN(float value) => float.IsNaN(value);

private protected override float? CalculateDifference(float? actual, float expected) => actual - expected;
}
}
18 changes: 18 additions & 0 deletions Src/FluentAssertions/Numeric/IntAssertions.cs
@@ -0,0 +1,18 @@
using System.Diagnostics;

namespace FluentAssertions.Numeric
{
/// <summary>
/// Contains a number of methods to assert that a <see cref="int"/> is in the expected state.
/// </summary>
[DebuggerNonUserCode]
public class IntAssertions : NumericAssertions<int>
iliashkolyar marked this conversation as resolved.
Show resolved Hide resolved
{
public IntAssertions(int value)
: base(value)
{
}

private protected override int? CalculateDifference(int? actual, int expected) => actual - expected;
}
}
18 changes: 18 additions & 0 deletions Src/FluentAssertions/Numeric/LongAssertions.cs
@@ -0,0 +1,18 @@
using System.Diagnostics;

namespace FluentAssertions.Numeric
{
/// <summary>
/// Contains a number of methods to assert that a <see cref="long"/> is in the expected state.
/// </summary>
[DebuggerNonUserCode]
public class LongAssertions : NumericAssertions<long>
{
public LongAssertions(long value)
: base(value)
{
}

private protected override long? CalculateDifference(long? actual, long expected) => actual - expected;
}
}
18 changes: 18 additions & 0 deletions Src/FluentAssertions/Numeric/NullableByteAssertions.cs
@@ -0,0 +1,18 @@
using System.Diagnostics;

namespace FluentAssertions.Numeric
{
/// <summary>
/// Contains a number of methods to assert that a nullable <see cref="byte"/> is in the expected state.
/// </summary>
[DebuggerNonUserCode]
public class NullableByteAssertions : NullableNumericAssertions<byte>
{
public NullableByteAssertions(byte? value)
: base(value)
{
}

private protected override byte? CalculateDifference(byte? actual, byte expected) => (byte?)(actual - expected);
}
}
18 changes: 18 additions & 0 deletions Src/FluentAssertions/Numeric/NullableDecimalAssertions.cs
@@ -0,0 +1,18 @@
using System.Diagnostics;

namespace FluentAssertions.Numeric
{
/// <summary>
/// Contains a number of methods to assert that a nullable <see cref="decimal"/> is in the expected state.
/// </summary>
[DebuggerNonUserCode]
public class NullableDecimalAssertions : NullableNumericAssertions<decimal>
{
public NullableDecimalAssertions(decimal? value)
: base(value)
{
}

private protected override decimal? CalculateDifference(decimal? actual, decimal expected) => actual - expected;
}
}
18 changes: 18 additions & 0 deletions Src/FluentAssertions/Numeric/NullableDoubleAssertions.cs
@@ -0,0 +1,18 @@
using System.Diagnostics;

namespace FluentAssertions.Numeric
{
/// <summary>
/// Contains a number of methods to assert that a nullable <see cref="double"/> is in the expected state.
/// </summary>
[DebuggerNonUserCode]
public class NullableDoubleAssertions : NullableNumericAssertions<double>
{
public NullableDoubleAssertions(double? value)
: base(value)
{
}

private protected override double? CalculateDifference(double? actual, double expected) => actual - expected;
}
}
18 changes: 18 additions & 0 deletions Src/FluentAssertions/Numeric/NullableFloatAssertions.cs
@@ -0,0 +1,18 @@
using System.Diagnostics;

namespace FluentAssertions.Numeric
{
/// <summary>
/// Contains a number of methods to assert that a nullable <see cref="float"/> is in the expected state.
/// </summary>
[DebuggerNonUserCode]
public class NullableFloatAssertions : NullableNumericAssertions<float>
{
public NullableFloatAssertions(float? value)
: base(value)
{
}

private protected override float? CalculateDifference(float? actual, float expected) => actual - expected;
}
}
18 changes: 18 additions & 0 deletions Src/FluentAssertions/Numeric/NullableIntAssertions.cs
@@ -0,0 +1,18 @@
using System.Diagnostics;

namespace FluentAssertions.Numeric
{
/// <summary>
/// Contains a number of methods to assert that a nullable <see cref="int"/> is in the expected state.
/// </summary>
[DebuggerNonUserCode]
public class NullableIntAssertions : NullableNumericAssertions<int>
{
public NullableIntAssertions(int? value)
: base(value)
{
}

private protected override int? CalculateDifference(int? actual, int expected) => actual - expected;
}
}