Skip to content

Commit

Permalink
Rewrote some tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corniel committed Jan 20, 2024
1 parent 63a0925 commit 355999a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
8 changes: 8 additions & 0 deletions specs/Qowaiv.Specs/Globalization/Country_specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ public class With_domain_logic
[TestCase(false, "?")]
[TestCase(false, "")]
public void IsKnown_is(bool result, Country svo) => svo.IsKnown.Should().Be(result);

/// <remarks>
/// As the regions available depend on the environment running, we can't
/// predict the outcome.
/// </remarks>
[TestCaseSource(typeof(Country), nameof(Country.All))]
public void RegionInfo_exists_indicates_counterpart_exists(Country country)
=> country.Invoking(c => c.RegionInfoExists).Should().NotThrow();
}

public class Display_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void IsEmptyOrUnknown_TestStruct_IsFalse()
public void TryParse_Null_IsValid()
{
BusinessIdentifierCode.TryParse(Nil.String, out BusinessIdentifierCode val).Should().BeTrue();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

/// <summary>TryParse string.Empty should be valid.</summary>
Expand All @@ -94,7 +94,7 @@ public void TryParse_StringEmpty_IsValid()
{
string str = string.Empty;
BusinessIdentifierCode.TryParse(str, out BusinessIdentifierCode val).Should().BeTrue();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

/// <summary>TryParse "?" should be valid and the result should be BusinessIdentifierCode.Unknown.</summary>
Expand All @@ -121,7 +121,7 @@ public void TryParse_StringValue_IsNotValid()
{
string str = "string";
BusinessIdentifierCode.TryParse(str, out BusinessIdentifierCode val).Should().BeFalse();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

[Test]
Expand Down
6 changes: 3 additions & 3 deletions specs/Qowaiv.Specs/_Legacy/Financial/CurrencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void IsEmptyOrUnknown_TestStruct_IsFalse()
public void TryParse_Null_IsValid()
{
Currency.TryParse(Nil.String, out Currency val).Should().BeTrue();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

/// <summary>TryParse string.Empty should be valid.</summary>
Expand All @@ -134,7 +134,7 @@ public void TryParse_StringEmpty_IsValid()
{
string str = string.Empty;
Currency.TryParse(str, out Currency val).Should().BeTrue();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

/// <summary>TryParse "?" should be valid and the result should be Currency.Unknown.</summary>
Expand Down Expand Up @@ -170,7 +170,7 @@ public void TryParse_StringValue_IsNotValid()
{
string str = "string";
Currency.TryParse(str, out Currency val).Should().BeFalse();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

[Test]
Expand Down
14 changes: 3 additions & 11 deletions specs/Qowaiv.Specs/_Legacy/Globalization/CountryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void IsEmpty_Default_IsFalse()
public void TryParse_Null_IsValid()
{
Country.TryParse(Nil.String, out Country val).Should().BeTrue();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

/// <summary>TryParse string.Empty should be valid.</summary>
Expand All @@ -86,7 +86,7 @@ public void TryParse_StringEmpty_IsValid()
{
string str = string.Empty;
Country.TryParse(str, out Country val).Should().BeTrue();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

/// <summary>TryParse "?" should be valid and the result should be Country.Unknown.</summary>
Expand Down Expand Up @@ -122,7 +122,7 @@ public void TryParse_StringValue_IsNotValid()
{
string str = "string";
Country.TryParse(str, out Country val).Should().BeFalse();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

[Test]
Expand Down Expand Up @@ -215,14 +215,6 @@ public void Create_CS_CSXX()
country.Should().Be(Country.CSXX);
}

[TestCaseSource(typeof(Country), nameof(Country.All))]
public void RegionInfoExists(Country country)
{
// As the regions available depend on the environment running, we can't
// predict the outcome.
new[] { true, false }.Contains(country.RegionInfoExists).Should().BeTrue();
}

#endregion

#region (XML) (De)serialization tests
Expand Down
6 changes: 3 additions & 3 deletions specs/Qowaiv.Specs/_Legacy/HouseNumberTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void IsEmptyOrUnknown_TestStruct_IsFalse()
public void TryParse_Null_IsValid()
{
HouseNumber.TryParse(Nil.String, out HouseNumber val).Should().BeTrue();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

/// <summary>TryParse string.Empty should be valid.</summary>
Expand All @@ -108,7 +108,7 @@ public void TryParse_StringEmpty_IsValid()
string str = string.Empty;

HouseNumber.TryParse(str, out HouseNumber val).Should().BeTrue();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

/// <summary>TryParse "?" should be valid and the result should be HouseNumber.Unknown.</summary>
Expand Down Expand Up @@ -138,7 +138,7 @@ public void TryParse_StringValue_IsNotValid()
string str = "string";

HouseNumber.TryParse(str, out HouseNumber val).Should().BeFalse();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

[Test]
Expand Down
6 changes: 3 additions & 3 deletions specs/Qowaiv.Specs/_Legacy/Web/InternetMediaTypeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void IsEmptyOrUnknown_TestStruct_IsFalse()
public void TryParse_Null_IsValid()
{
InternetMediaType.TryParse(Nil.String, out var val).Should().BeTrue();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

/// <summary>TryParse string.Empty should be valid.</summary>
Expand All @@ -102,7 +102,7 @@ public void TryParse_StringEmpty_IsValid()
string str = string.Empty;

InternetMediaType.TryParse(str, out var val).Should().BeTrue();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

/// <summary>TryParse "?" should be valid and the result should be InternetMediaType.Unknown.</summary>
Expand Down Expand Up @@ -132,7 +132,7 @@ public void TryParse_StringValue_IsNotValid()
string str = "string";

InternetMediaType.TryParse(str, out var val).Should().BeFalse();
Assert.AreEqual(string.Empty, val.ToString(), "Value");
val.Should().Be(default);
}

[Test]
Expand Down

0 comments on commit 355999a

Please sign in to comment.