Skip to content

Commit

Permalink
Update remaining Asserts (except legacy tests).
Browse files Browse the repository at this point in the history
  • Loading branch information
Corniel committed Mar 28, 2024
1 parent 8b2ba9e commit c797a7c
Show file tree
Hide file tree
Showing 27 changed files with 79 additions and 79 deletions.
6 changes: 3 additions & 3 deletions specs/Qowaiv.Specs/Chemistry/CAS_Registry_Number_specs.cs
Expand Up @@ -441,8 +441,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(CasRegistryNumber))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(CasRegistryNumber))
.Should().Be(new OpenApiDataType(
dataType: typeof(CasRegistryNumber),
description: "CAS Registry Number",
example: "7732-18-5",
Expand All @@ -454,7 +454,7 @@ public void with_info()
[TestCase("7732-18-5")]
[TestCase("10028-14-5")]
public void pattern_matches(string input)
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(CasRegistryNumber))!.Matches(input).Should().BeTrue();
=> OpenApiDataType.FromType(typeof(CasRegistryNumber))!.Matches(input).Should().BeTrue();
}

#if NET8_0_OR_GREATER
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Customization/Generic_SVO_specs.cs
Expand Up @@ -413,8 +413,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(ForCustomSvo))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(ForCustomSvo))
.Should().Be(new OpenApiDataType(
dataType: typeof(CustomSvo),
description: "Custom SVO Example",
example: "QOWAIV",
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Date_span_specs.cs
Expand Up @@ -114,8 +114,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(DateSpan))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(DateSpan))
.Should().Be(new OpenApiDataType(
dataType: typeof(DateSpan),
description: "Date span, specified in years, months and days.",
example: "1Y+10M+16D",
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Date_specs.cs
Expand Up @@ -234,8 +234,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(Date))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(Date))
.Should().Be(new OpenApiDataType(
dataType: typeof(Date),
description: "Full-date notation as defined by RFC 3339, section 5.6.",
example: "2017-06-10",
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Email_address_specs.cs
Expand Up @@ -447,8 +447,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(EmailAddress))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(EmailAddress))
.Should().Be(new OpenApiDataType(
dataType: typeof(EmailAddress),
description: "Email notation as defined by RFC 5322.",
type: "string",
Expand Down
6 changes: 3 additions & 3 deletions specs/Qowaiv.Specs/Financial/IBAN_specs.cs
Expand Up @@ -527,8 +527,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(InternationalBankAccountNumber))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(InternationalBankAccountNumber))
.Should().Be(new OpenApiDataType(
dataType: typeof(InternationalBankAccountNumber),
description: "International Bank Account Number notation as defined by ISO 13616:2007.",
example: "BE71096123456769",
Expand All @@ -539,7 +539,7 @@ public void with_info()

[TestCase("NL20INGB0001234567")]
public void pattern_matches(string input)
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(InternationalBankAccountNumber))!.Matches(input).Should().BeTrue();
=> OpenApiDataType.FromType(typeof(InternationalBankAccountNumber))!.Matches(input).Should().BeTrue();
}

#if NET8_0_OR_GREATER
Expand Down
10 changes: 5 additions & 5 deletions specs/Qowaiv.Specs/FluentAssertions/UuidAssertions.cs
@@ -1,4 +1,5 @@
using FluentAssertions.Numeric;
using FluentAssertions.Execution;
using FluentAssertions.Numeric;

namespace FluentAssertions;

Expand Down Expand Up @@ -39,11 +40,10 @@ public static AndConstraint<ComparableTypeAssertions<Uuid>> HavePattern(this Com
}
}

if (fail)
{
Assert.Fail($@"Expected: [{(string.Join(", ", exp))}]
Execute.Assertion
.ForCondition(!fail)
.WithExpectation($@"Expected: [{(string.Join(", ", exp))}]
Actual: [{(string.Join(", ", act))}]");
}

subject.Version.Should().Be(UuidVersion.Sequential);

Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/HouseNumber_specs.cs
Expand Up @@ -156,8 +156,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(HouseNumber))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(HouseNumber))
.Should().Be(new OpenApiDataType(
dataType: typeof(HouseNumber),
description: "House number notation.",
example: "13",
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/IO/StreamSize_specs.cs
Expand Up @@ -269,8 +269,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(StreamSize))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(StreamSize))
.Should().Be(new OpenApiDataType(
dataType: typeof(StreamSize),
description: "Stream size notation (in byte).",
example: 1024,
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Identifiers/Id_for_Int32_specs.cs
Expand Up @@ -170,8 +170,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(ForInt32))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(ForInt32))
.Should().Be(new OpenApiDataType(
dataType: typeof(Int32Id),
description: "Int32 based identifier",
example: 17,
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Identifiers/Id_for_Int64_specs.cs
Expand Up @@ -181,8 +181,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(ForInt64))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(ForInt64))
.Should().Be(new OpenApiDataType(
dataType: typeof(Int64Id),
description: "Int64 based identifier",
example: 17,
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Identifiers/Id_for_String_specs.cs
Expand Up @@ -103,8 +103,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(ForString))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(ForString))
.Should().Be(new OpenApiDataType(
dataType: typeof(StringId),
description: "String based identifier",
example: "Order-UK-2022-215",
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Mathematics/Fraction_specs.cs
Expand Up @@ -937,8 +937,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(Fraction))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(Fraction))
.Should().Be(new OpenApiDataType(
dataType: typeof(Fraction),
description: "Faction",
type: "string",
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Month_span_specs.cs
Expand Up @@ -261,8 +261,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(MonthSpan))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(MonthSpan))
.Should().Be(new OpenApiDataType(
dataType: typeof(MonthSpan),
description: "Month span, specified in years and months.",
example: "1Y+10M",
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Month_specs.cs
Expand Up @@ -538,8 +538,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(Month))
.Should().BeEquivalentTo(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(Month))
.Should().BeEquivalentTo(new OpenApiDataType(
dataType: typeof(Month),
description: "Month(-only) notation.",
type: "string",
Expand Down
27 changes: 14 additions & 13 deletions specs/Qowaiv.Specs/Percentage_specs.cs
@@ -1,4 +1,6 @@
namespace Percentage_specs;
using FluentAssertions;

namespace Percentage_specs;

public class Is_valid_for
{
Expand Down Expand Up @@ -582,7 +584,7 @@ public void _double()
public void _float()
{
var addition = 34.586f + 75.Percent();
Assert.That(addition, Is.EqualTo(60.5255f).Within(0.00001));
addition.Should().BeApproximately(60.5255f, 0.00001f);
}

[Test]
Expand Down Expand Up @@ -749,14 +751,14 @@ public void _decimal()
public void _double()
{
var addition = 34.586 * 75.Percent();
Assert.That(addition, Is.EqualTo(25.9395).Within(0.00001));
addition.Should().BeApproximately(25.9395, 0.00001);
}

[Test]
public void _float()
{
var addition = 34.586f * 75.Percent();
Assert.That(addition, Is.EqualTo(25.9395f).Within(0.00001));
addition.Should().BeApproximately(25.9395f, 0.00001f);
}

[Test]
Expand Down Expand Up @@ -829,21 +831,21 @@ public void _money()
public void _decimal()
{
var addition = 34.586m / 75.Percent();
Assert.That(addition, Is.EqualTo(46.11467m).Within(0.00001));
addition.Should().BeApproximately(46.11467m, 0.00001m);
}

[Test]
public void _double()
{
var addition = 34.586 / 75.Percent();
Assert.That(addition, Is.EqualTo(46.11467).Within(0.00001));
addition.Should().BeApproximately(46.11467, 0.00001);
}

[Test]
public void _float()
{
var addition = 34.586f / 75.Percent();
Assert.That(addition, Is.EqualTo(46.11467f).Within(0.00001));
addition.Should().BeApproximately(46.11467f, 0.00001f);
}

[Test]
Expand Down Expand Up @@ -935,9 +937,8 @@ public void up_to_26_digits(int decimals)

[Test]
public void up_to_minus_26_digits()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Svo.Percentage.Round(-27));
}
=> (-27).Invoking(Svo.Percentage.Round)
.Should().Throw<ArgumentOutOfRangeException>();

[Test, Obsolete("Only exists for guidance towards decimal rounding methods.")]
public void using_system_midpoint_rounding()
Expand Down Expand Up @@ -1172,8 +1173,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(Percentage))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(Percentage))
.Should().Be(new OpenApiDataType(
dataType: typeof(Percentage),
description: "Ratio expressed as a fraction of 100 denoted using the percent sign '%'.",
type: "string",
Expand All @@ -1186,7 +1187,7 @@ public void with_info()
[TestCase("-0.1%")]
[TestCase("31%")]
public void pattern_matches(string input)
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(Percentage))!.Matches(input).Should().BeTrue();
=> OpenApiDataType.FromType(typeof(Percentage))!.Matches(input).Should().BeTrue();
}

#if NET8_0_OR_GREATER
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Postal_code_specs.cs
Expand Up @@ -429,8 +429,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(PostalCode))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(PostalCode))
.Should().Be(new OpenApiDataType(
dataType: typeof(PostalCode),
description: "Postal code notation.",
type: "string",
Expand Down
6 changes: 2 additions & 4 deletions specs/Qowaiv.Specs/Reflection/QowaivType_specs.cs
Expand Up @@ -40,13 +40,11 @@ public class NotNullableType
[TestCase(typeof(string))]
[TestCase(typeof(int))]
public void Returns_type_for_non_nullable(Type type)
#pragma warning disable FAA0004 // Replace NUnit assertion with Fluent Assertions equivalent
=> Assert.That(QowaivType.GetNotNullableType(type), Is.EqualTo(type));
#pragma warning restore FAA0004 // Replace NUnit assertion with Fluent Assertions equivalent
=> QowaivType.GetNotNullableType(type).Should().Be(type);

[Test]
public void Returns_underlying_type_for_nullable()
=> Assert.That(QowaivType.GetNotNullableType(typeof(int?)), Is.EqualTo(typeof(int)));
=> QowaivType.GetNotNullableType(typeof(int?)).Should().Be(typeof(int));
}

public class IsNumeric
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Sex_specs.cs
Expand Up @@ -432,8 +432,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(Sex))
.Should().BeEquivalentTo(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(Sex))
.Should().BeEquivalentTo(new OpenApiDataType(
dataType: typeof(Sex),
description: "Sex as specified by ISO/IEC 5218.",
type: "string",
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Sql/Timestamp_specs.cs
Expand Up @@ -128,8 +128,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(Timestamp))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(Timestamp))
.Should().Be(new OpenApiDataType(
dataType: typeof(Timestamp),
description: "SQL Server timestamp notation.",
example: "0x00000000000007D9",
Expand Down
4 changes: 2 additions & 2 deletions specs/Qowaiv.Specs/Statistics/Elo_specs.cs
Expand Up @@ -178,8 +178,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(Elo))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(Elo))
.Should().Be(new OpenApiDataType(
dataType: typeof(Elo),
description: "Elo rating system notation.",
example: 1600d,
Expand Down
6 changes: 3 additions & 3 deletions specs/Qowaiv.Specs/Sustainability/Energy_label_specs.cs
Expand Up @@ -528,8 +528,8 @@ public class Is_Open_API_data_type
{
[Test]
public void with_info()
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(EnergyLabel))
.Should().Be(new Qowaiv.OpenApi.OpenApiDataType(
=> OpenApiDataType.FromType(typeof(EnergyLabel))
.Should().Be(new OpenApiDataType(
dataType: typeof(EnergyLabel),
description: "EU energy label",
example: "A++",
Expand All @@ -544,7 +544,7 @@ public void with_info()
[TestCase("A+")]
[TestCase("A++++")]
public void pattern_matches(string input)
=> Qowaiv.OpenApi.OpenApiDataType.FromType(typeof(EnergyLabel))!.Matches(input).Should().BeTrue();
=> OpenApiDataType.FromType(typeof(EnergyLabel))!.Matches(input).Should().BeTrue();
}

#if NET8_0_OR_GREATER
Expand Down

0 comments on commit c797a7c

Please sign in to comment.