Skip to content

Commit

Permalink
fix: xUnit1042 for better type safety (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtrion authored Jan 3, 2024
1 parent 3ce9fef commit d5041cb
Show file tree
Hide file tree
Showing 24 changed files with 151 additions and 139 deletions.
2 changes: 2 additions & 0 deletions src/NetEvolve.Guard/NetEvolve.Guard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<TargetFrameworks>netstandard2.0;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>

<DisableBannedApiForPerformance>true</DisableBannedApiForPerformance>

<NoWarn>$(NoWarn);S3236</NoWarn>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/NetEvolve.Guard.Tests.Unit/EnsureArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void NotNullOrEmpty_Theory_Expected(bool throwException, string?[] values
}
}

public static TheoryData GetNotNullOrEmptyData =>
public static TheoryData<bool, string?[]> GetNotNullOrEmptyData =>
new TheoryData<bool, string?[]>
{
{ true, Array.Empty<string?>() },
Expand Down
14 changes: 7 additions & 7 deletions tests/NetEvolve.Guard.Tests.Unit/EnsureBigIntegerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ BigInteger compareValue
}
}

public static TheoryData GetInBetweenData =>
public static TheoryData<bool, BigInteger, BigInteger, BigInteger> GetInBetweenData =>
new TheoryData<bool, BigInteger, BigInteger, BigInteger>
{
{ true, MinValue, BaseValue, MaxValue },
Expand All @@ -154,7 +154,7 @@ BigInteger compareValue
{ false, BaseValue, MaxValue, MinValue }
};

public static TheoryData GetNotBetweenData =>
public static TheoryData<bool, BigInteger, BigInteger, BigInteger> GetNotBetweenData =>
new TheoryData<bool, BigInteger, BigInteger, BigInteger>
{
{ false, MinValue, BaseValue, MaxValue },
Expand All @@ -163,31 +163,31 @@ BigInteger compareValue
{ true, BaseValue, MaxValue, MinValue }
};

public static TheoryData GetGreaterThanData =>
public static TheoryData<bool, BigInteger, BigInteger> GetGreaterThanData =>
new TheoryData<bool, BigInteger, BigInteger>
{
{ true, BaseValue, MaxValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetGreaterThanOrEqualData =>
public static TheoryData<bool, BigInteger, BigInteger> GetGreaterThanOrEqualData =>
new TheoryData<bool, BigInteger, BigInteger>
{
{ true, BaseValue, MaxValue },
{ false, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetLessThanData =>
public static TheoryData<bool, BigInteger, BigInteger> GetLessThanData =>
new TheoryData<bool, BigInteger, BigInteger>
{
{ true, BaseValue, MinValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MaxValue }
};

public static TheoryData GetLessThanOrEqualData =>
public static TheoryData<bool, BigInteger, BigInteger> GetLessThanOrEqualData =>
new TheoryData<bool, BigInteger, BigInteger>
{
{ true, BaseValue, MinValue },
Expand All @@ -213,7 +213,7 @@ public void NotPow2_Theory_Expected(bool throwException, BigInteger value)
}
}

public static TheoryData GetNotPow2Data =>
public static TheoryData<bool, BigInteger> GetNotPow2Data =>
new TheoryData<bool, BigInteger> { { true, 63 }, { false, 64 } };
#endif
}
12 changes: 6 additions & 6 deletions tests/NetEvolve.Guard.Tests.Unit/EnsureCharTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void LessThanOrEqual_Theory_Expected(bool throwException, char value, cha
}
}

public static TheoryData GetInBetweenData =>
public static TheoryData<bool, char, char, char> GetInBetweenData =>
new TheoryData<bool, char, char, char>
{
{ true, MinValue, BaseValue, MaxValue },
Expand All @@ -131,7 +131,7 @@ public void LessThanOrEqual_Theory_Expected(bool throwException, char value, cha
{ false, BaseValue, MaxValue, MinValue }
};

public static TheoryData GetNotBetweenData =>
public static TheoryData<bool, char, char, char> GetNotBetweenData =>
new TheoryData<bool, char, char, char>
{
{ true, BaseValue, MinValue, MaxValue },
Expand All @@ -140,31 +140,31 @@ public void LessThanOrEqual_Theory_Expected(bool throwException, char value, cha
{ false, MaxValue, BaseValue, MinValue }
};

public static TheoryData GetGreaterThanData =>
public static TheoryData<bool, char, char> GetGreaterThanData =>
new TheoryData<bool, char, char>
{
{ true, BaseValue, MaxValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetGreaterThanOrEqualData =>
public static TheoryData<bool, char, char> GetGreaterThanOrEqualData =>
new TheoryData<bool, char, char>
{
{ true, BaseValue, MaxValue },
{ false, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetLessThanData =>
public static TheoryData<bool, char, char> GetLessThanData =>
new TheoryData<bool, char, char>
{
{ true, BaseValue, MinValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MaxValue }
};

public static TheoryData GetLessThanOrEqualData =>
public static TheoryData<bool, char, char> GetLessThanOrEqualData =>
new TheoryData<bool, char, char>
{
{ true, BaseValue, MinValue },
Expand Down
12 changes: 6 additions & 6 deletions tests/NetEvolve.Guard.Tests.Unit/EnsureDateOnlyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ DateOnly compareValue
}
}

public static TheoryData GetInBetweenData =>
public static TheoryData<bool, DateOnly, DateOnly, DateOnly> GetInBetweenData =>
new TheoryData<bool, DateOnly, DateOnly, DateOnly>
{
{ true, MinValue, BaseValue, MaxValue },
Expand All @@ -150,7 +150,7 @@ DateOnly compareValue
{ false, BaseValue, MaxValue, MinValue }
};

public static TheoryData GetNotBetweenData =>
public static TheoryData<bool, DateOnly, DateOnly, DateOnly> GetNotBetweenData =>
new TheoryData<bool, DateOnly, DateOnly, DateOnly>
{
{ false, MinValue, BaseValue, MaxValue },
Expand All @@ -159,31 +159,31 @@ DateOnly compareValue
{ true, BaseValue, MaxValue, MinValue }
};

public static TheoryData GetGreaterThanData =>
public static TheoryData<bool, DateOnly, DateOnly> GetGreaterThanData =>
new TheoryData<bool, DateOnly, DateOnly>
{
{ true, BaseValue, MaxValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetGreaterThanOrEqualData =>
public static TheoryData<bool, DateOnly, DateOnly> GetGreaterThanOrEqualData =>
new TheoryData<bool, DateOnly, DateOnly>
{
{ true, BaseValue, MaxValue },
{ false, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetLessThanData =>
public static TheoryData<bool, DateOnly, DateOnly> GetLessThanData =>
new TheoryData<bool, DateOnly, DateOnly>
{
{ true, BaseValue, MinValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MaxValue }
};

public static TheoryData GetLessThanOrEqualData =>
public static TheoryData<bool, DateOnly, DateOnly> GetLessThanOrEqualData =>
new TheoryData<bool, DateOnly, DateOnly>
{
{ true, BaseValue, MinValue },
Expand Down
22 changes: 16 additions & 6 deletions tests/NetEvolve.Guard.Tests.Unit/EnsureDateTimeOffsetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ DateTimeOffset compareValue
}
}

public static TheoryData GetInBetweenData =>
public static TheoryData<
bool,
DateTimeOffset,
DateTimeOffset,
DateTimeOffset
> GetInBetweenData =>
new TheoryData<bool, DateTimeOffset, DateTimeOffset, DateTimeOffset>
{
{ true, MinValue, BaseValue, MaxValue },
Expand All @@ -153,7 +158,12 @@ DateTimeOffset compareValue
{ false, BaseValue, MaxValue, MinValue }
};

public static TheoryData GetNotBetweenData =>
public static TheoryData<
bool,
DateTimeOffset,
DateTimeOffset,
DateTimeOffset
> GetNotBetweenData =>
new TheoryData<bool, DateTimeOffset, DateTimeOffset, DateTimeOffset>
{
{ false, MinValue, BaseValue, MaxValue },
Expand All @@ -162,31 +172,31 @@ DateTimeOffset compareValue
{ true, BaseValue, MaxValue, MinValue }
};

public static TheoryData GetGreaterThanData =>
public static TheoryData<bool, DateTimeOffset, DateTimeOffset> GetGreaterThanData =>
new TheoryData<bool, DateTimeOffset, DateTimeOffset>
{
{ true, BaseValue, MaxValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetGreaterThanOrEqualData =>
public static TheoryData<bool, DateTimeOffset, DateTimeOffset> GetGreaterThanOrEqualData =>
new TheoryData<bool, DateTimeOffset, DateTimeOffset>
{
{ true, BaseValue, MaxValue },
{ false, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetLessThanData =>
public static TheoryData<bool, DateTimeOffset, DateTimeOffset> GetLessThanData =>
new TheoryData<bool, DateTimeOffset, DateTimeOffset>
{
{ true, BaseValue, MinValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MaxValue }
};

public static TheoryData GetLessThanOrEqualData =>
public static TheoryData<bool, DateTimeOffset, DateTimeOffset> GetLessThanOrEqualData =>
new TheoryData<bool, DateTimeOffset, DateTimeOffset>
{
{ true, BaseValue, MinValue },
Expand Down
12 changes: 6 additions & 6 deletions tests/NetEvolve.Guard.Tests.Unit/EnsureDateTimeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ DateTime compareValue
}
}

public static TheoryData GetInBetweenData =>
public static TheoryData<bool, DateTime, DateTime, DateTime> GetInBetweenData =>
new TheoryData<bool, DateTime, DateTime, DateTime>
{
{ true, MinValue, BaseValue, MaxValue },
Expand All @@ -149,7 +149,7 @@ DateTime compareValue
{ false, BaseValue, MaxValue, MinValue }
};

public static TheoryData GetNotBetweenData =>
public static TheoryData<bool, DateTime, DateTime, DateTime> GetNotBetweenData =>
new TheoryData<bool, DateTime, DateTime, DateTime>
{
{ false, MinValue, BaseValue, MaxValue },
Expand All @@ -158,31 +158,31 @@ DateTime compareValue
{ true, BaseValue, MaxValue, MinValue }
};

public static TheoryData GetGreaterThanData =>
public static TheoryData<bool, DateTime, DateTime> GetGreaterThanData =>
new TheoryData<bool, DateTime, DateTime>
{
{ true, BaseValue, MaxValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetGreaterThanOrEqualData =>
public static TheoryData<bool, DateTime, DateTime> GetGreaterThanOrEqualData =>
new TheoryData<bool, DateTime, DateTime>
{
{ true, BaseValue, MaxValue },
{ false, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetLessThanData =>
public static TheoryData<bool, DateTime, DateTime> GetLessThanData =>
new TheoryData<bool, DateTime, DateTime>
{
{ true, BaseValue, MinValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MaxValue }
};

public static TheoryData GetLessThanOrEqualData =>
public static TheoryData<bool, DateTime, DateTime> GetLessThanOrEqualData =>
new TheoryData<bool, DateTime, DateTime>
{
{ true, BaseValue, MinValue },
Expand Down
12 changes: 6 additions & 6 deletions tests/NetEvolve.Guard.Tests.Unit/EnsureDecimalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ decimal compareValue
}
}

public static TheoryData GetInBetweenData =>
public static TheoryData<bool, decimal, decimal, decimal> GetInBetweenData =>
new TheoryData<bool, decimal, decimal, decimal>
{
{ true, MinValue, BaseValue, MaxValue },
Expand All @@ -149,7 +149,7 @@ decimal compareValue
{ false, BaseValue, MaxValue, MinValue }
};

public static TheoryData GetNotBetweenData =>
public static TheoryData<bool, decimal, decimal, decimal> GetNotBetweenData =>
new TheoryData<bool, decimal, decimal, decimal>
{
{ false, MinValue, BaseValue, MaxValue },
Expand All @@ -158,31 +158,31 @@ decimal compareValue
{ true, BaseValue, MaxValue, MinValue }
};

public static TheoryData GetGreaterThanData =>
public static TheoryData<bool, decimal, decimal> GetGreaterThanData =>
new TheoryData<bool, decimal, decimal>
{
{ true, BaseValue, MaxValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetGreaterThanOrEqualData =>
public static TheoryData<bool, decimal, decimal> GetGreaterThanOrEqualData =>
new TheoryData<bool, decimal, decimal>
{
{ true, BaseValue, MaxValue },
{ false, BaseValue, BaseValue },
{ false, BaseValue, MinValue }
};

public static TheoryData GetLessThanData =>
public static TheoryData<bool, decimal, decimal> GetLessThanData =>
new TheoryData<bool, decimal, decimal>
{
{ true, BaseValue, MinValue },
{ true, BaseValue, BaseValue },
{ false, BaseValue, MaxValue }
};

public static TheoryData GetLessThanOrEqualData =>
public static TheoryData<bool, decimal, decimal> GetLessThanOrEqualData =>
new TheoryData<bool, decimal, decimal>
{
{ true, BaseValue, MinValue },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Exists_Theory_Expected(bool throwException, string directoryPath)
}
}

public static TheoryData GetExistsData =>
public static TheoryData<bool, string> GetExistsData =>
new TheoryData<bool, string>
{
{ true, "/does.not.exists/" },
Expand Down
Loading

0 comments on commit d5041cb

Please sign in to comment.