Skip to content

Commit

Permalink
Merge branch 'develop' into code-style-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ITaluone committed Apr 6, 2022
2 parents a2d6521 + d53e8d9 commit 55d1835
Show file tree
Hide file tree
Showing 49 changed files with 1,934 additions and 123 deletions.
40 changes: 20 additions & 20 deletions Src/FluentAssertions/AssertionExtensions.cs
Original file line number Diff line number Diff line change
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 Int32Assertions(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 NullableInt32Assertions(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 UInt32Assertions(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 NullableUInt32Assertions(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 Int16Assertions(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 NullableInt16Assertions(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 UInt16Assertions(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 NullableUInt16Assertions(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 Int64Assertions(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 NullableInt64Assertions(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 UInt64Assertions(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 NullableUInt64Assertions(actualValue);
}

/// <summary>
Expand All @@ -676,7 +676,7 @@ public static NullableNumericAssertions<ulong> Should(this ulong? actualValue)
[Pure]
public static NumericAssertions<float> Should(this float actualValue)
{
return new FloatAssertions(actualValue);
return new SingleAssertions(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 NullableFloatAssertions(actualValue);
return new NullableSingleAssertions(actualValue);
}

/// <summary>
Expand Down
8 changes: 0 additions & 8 deletions Src/FluentAssertions/Common/Guard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ public static void ThrowIfArgumentContainsNull<T>(IEnumerable<T> values, string
}
}

public static void ThrowIfArgumentContainsNull<T>(IEnumerable<T> values, string paramName, string message)
{
if (values.Any(t => t is null))
{
throw new ArgumentNullException(paramName, message);
}
}

public static void ThrowIfArgumentIsEmpty<T>(IEnumerable<T> values, string paramName, string message)
{
if (!values.Any())
Expand Down
23 changes: 23 additions & 0 deletions Src/FluentAssertions/Numeric/ByteAssertions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Diagnostics;
using System.Globalization;

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

private protected override string CalculateDifferenceForFailureMessage(byte subject, byte expected)
{
int difference = subject - expected;
return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;
}
}
}
31 changes: 31 additions & 0 deletions Src/FluentAssertions/Numeric/DecimalAssertions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Diagnostics;
using System.Globalization;

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

private protected override string CalculateDifferenceForFailureMessage(decimal subject, decimal expected)
{
try
{
decimal difference = checked(subject - expected);
return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;
}
catch (OverflowException)
{
return null;
}
}
}
}
17 changes: 15 additions & 2 deletions Src/FluentAssertions/Numeric/DoubleAssertions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
namespace FluentAssertions.Numeric
using System.Diagnostics;
using System.Globalization;

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

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

private protected override string CalculateDifferenceForFailureMessage(double subject, double expected)
{
var difference = subject - expected;
return difference != 0 ? difference.ToString("R", CultureInfo.InvariantCulture) : null;
}
}
}
12 changes: 0 additions & 12 deletions Src/FluentAssertions/Numeric/FloatAssertions.cs

This file was deleted.

28 changes: 28 additions & 0 deletions Src/FluentAssertions/Numeric/Int16Assertions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Diagnostics;
using System.Globalization;

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

private protected override string CalculateDifferenceForFailureMessage(short subject, short expected)
{
if (subject < 10 && expected < 10)
{
return null;
}

int difference = subject - expected;
return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;
}
}
}
28 changes: 28 additions & 0 deletions Src/FluentAssertions/Numeric/Int32Assertions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Diagnostics;
using System.Globalization;

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

private protected override string CalculateDifferenceForFailureMessage(int subject, int expected)
{
if (subject is > 0 and < 10 && expected is > 0 and < 10)
{
return null;
}

long difference = (long)subject - expected;
return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;
}
}
}
28 changes: 28 additions & 0 deletions Src/FluentAssertions/Numeric/Int64Assertions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Diagnostics;
using System.Globalization;

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

private protected override string CalculateDifferenceForFailureMessage(long subject, long expected)
{
if (subject is > 0 and < 10 && expected is > 0 and < 10)
{
return null;
}

decimal difference = (decimal)subject - expected;
return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;
}
}
}
Loading

0 comments on commit 55d1835

Please sign in to comment.