Skip to content

Commit

Permalink
Add some null strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corniel Nobel committed May 3, 2023
1 parent 6cd6657 commit e08842e
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ public void IsEmptyOrUnknown_TestStruct_IsFalse()
[Test]
public void TryParse_Null_IsValid()
{
string str = null;
Assert.IsTrue(Currency.TryParse(str, out Currency val), "Valid");
Assert.IsTrue(Currency.TryParse(Nil.String, out Currency val), "Valid");
Assert.AreEqual(string.Empty, val.ToString(), "Value");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public void IsEmpty_Default_IsFalse()
[Test]
public void TryParse_Null_IsValid()
{
string str = null;
Assert.IsTrue(InternationalBankAccountNumber.TryParse(str, out var val), "Valid");
Assert.IsTrue(InternationalBankAccountNumber.TryParse(Nil.String, out var val), "Valid");
Assert.AreEqual(string.Empty, val.ToString(), "Value");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void OperatorIsNot_TestStructTestStruct_IsFalse()
[Test]
public void Format_DefaultValue_StringNull()
{
var exp = (String)null;
var exp = Nil.String;
var act = FormattingArguments.None.Format;
Assert.AreEqual(exp, act);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public void IsEmpty_Default_IsFalse()
[Test]
public void TryParse_Null_IsValid()
{
string str = null;
Assert.IsTrue(Country.TryParse(str, out Country val), "Valid");
Assert.IsTrue(Country.TryParse(Nil.String, out Country val), "Valid");
Assert.AreEqual(string.Empty, val.ToString(), "Value");
}

Expand Down Expand Up @@ -176,15 +175,15 @@ public void from_invalid_as_null_with_TryParse()
public void Create_RegionInfoNull_Empty()
{
var exp = Country.Empty;
var act = Country.Create((RegionInfo)null);
var act = Country.Create(Nil.Obj<RegionInfo>());
Assert.AreEqual(exp, act);
}

[Test]
public void Create_CultureInfoNull_Empty()
{
var exp = Country.Empty;
var act = Country.Create((CultureInfo)null);
var act = Country.Create(Nil.Obj<CultureInfo>());
Assert.AreEqual(exp, act);
}

Expand Down
4 changes: 1 addition & 3 deletions specs/Qowaiv.Specs/UnitTests.OldStyle/HouseNumberTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ public void IsEmptyOrUnknown_TestStruct_IsFalse()
[Test]
public void TryParse_Null_IsValid()
{
string str = null;

Assert.IsTrue(HouseNumber.TryParse(str, out HouseNumber val), "Valid");
Assert.IsTrue(HouseNumber.TryParse(Nil.String, out HouseNumber val), "Valid");
Assert.AreEqual(string.Empty, val.ToString(), "Value");
}

Expand Down
2 changes: 1 addition & 1 deletion specs/Qowaiv.Specs/UnitTests.OldStyle/IO/StreamSizeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public void ToString_CustomFormatter_SupportsCustomFormatting()
[Test]
public void ToString_Null_ComplexPattern()
{
var act = TestStruct.ToString((String)null);
var act = TestStruct.ToString(Nil.String);
var exp = "123456789";
Assert.AreEqual(exp, act);
}
Expand Down
3 changes: 1 addition & 2 deletions specs/Qowaiv.Specs/UnitTests.OldStyle/LocalDateTimeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public void MinValue_None_EqualsDefault()
[Test]
public void TryParse_Null_IsNotValid()
{
string str = null;
Assert.IsFalse(LocalDateTime.TryParse(str, out _), "Valid");
Assert.IsFalse(LocalDateTime.TryParse(Nil.String, out _), "Valid");
}

/// <summary>TryParse string.MinValue should be valid.</summary>
Expand Down
3 changes: 1 addition & 2 deletions specs/Qowaiv.Specs/UnitTests.OldStyle/Statistics/EloTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public void GetZScore_Delta100_0Dot64()
[Test]
public void TryParse_Null_IsNotValid()
{
string str = null;
Assert.IsFalse(Elo.TryParse(str, out _), "Valid");
Assert.IsFalse(Elo.TryParse(Nil.String, out _), "Valid");
}

/// <summary>TryParse string.Empty should not be valid.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ public void IsEmptyOrUnknown_TestStruct_IsFalse()
[Test]
public void TryParse_Null_IsValid()
{
string str = null;

Assert.IsTrue(InternetMediaType.TryParse(str, out var val), "Valid");
Assert.IsTrue(InternetMediaType.TryParse(Nil.String, out var val), "Valid");
Assert.AreEqual(string.Empty, val.ToString(), "Value");
}

Expand Down Expand Up @@ -185,7 +183,7 @@ public void from_invalid_as_null_with_TryParse()
[Test]
public void FromFile_NullFileInfo_Empty()
{
var act = InternetMediaType.FromFile((FileInfo)null);
var act = InternetMediaType.FromFile(Nil.Obj<FileInfo>());
var exp = InternetMediaType.Empty;

Assert.AreEqual(exp, act);
Expand All @@ -194,7 +192,7 @@ public void FromFile_NullFileInfo_Empty()
[Test]
public void FromFile_NullString_Empty()
{
var act = InternetMediaType.FromFile((String)null);
var act = InternetMediaType.FromFile(Nil.String);
var exp = InternetMediaType.Empty;

Assert.AreEqual(exp, act);
Expand Down
4 changes: 2 additions & 2 deletions src/Qowaiv/Globalization/Country.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public static bool TryParse(string? s, IFormatProvider? formatProvider, out Coun
/// Returns a country that represents the same region as region info.
/// </returns>
[Pure]
public static Country Create(RegionInfo region)
public static Country Create(RegionInfo? region)
{
if (region == null) { return default; }
// In .NET, Serbia and Montenegro (CS) is still active.
Expand All @@ -285,7 +285,7 @@ public static Country Create(RegionInfo region)
/// any, otherwise Empty.
/// </returns>
[Pure]
public static Country Create(CultureInfo culture)
public static Country Create(CultureInfo? culture)
{
if (culture == null || culture == CultureInfo.InvariantCulture || culture.IsNeutralCulture)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Qowaiv/Web/InternetMediaType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out InternetMe
/// Based on the extension of the file.
/// </remarks>
[Pure]
public static InternetMediaType FromFile(FileInfo file)
public static InternetMediaType FromFile(FileInfo? file)
=> file is null
? Empty
: FromFile(file.Name);
Expand All @@ -196,7 +196,7 @@ public static InternetMediaType FromFile(FileInfo file)
/// Based on the extension of the filename.
/// </remarks>
[Pure]
public static InternetMediaType FromFile(string filename)
public static InternetMediaType FromFile(string? filename)
{
if (string.IsNullOrEmpty(filename))
{
Expand Down

0 comments on commit e08842e

Please sign in to comment.