-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate not equal collection cases for Equals/GetHashCode / Refactor…
… tests
- Loading branch information
Showing
19 changed files
with
154 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
...parers/Collections.Generic.EqualityComparers.Tests/CaseSources/CaseSources.EqualArrays.cs
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
...lections.Generic.EqualityComparers.Tests/CaseSources/CaseSources.Equals_NotEqualArrays.cs
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
...ons.Generic.EqualityComparers.Tests/CaseSources/CaseSources.GetHashCode_NotEqualArrays.cs
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...-equalitycomparers/Collections.Generic.EqualityComparers.Tests/CaseSources/CaseSources.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...rers/Collections.Generic.EqualityComparers.Tests/CaseSources/NotEqualCaseSource_Equals.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
internal static partial class NotEqualCaseSource_Equals | ||
{ | ||
internal static IEnumerable<(T[]? X, T[]? Y)> NotEqualArrays<T>() | ||
=> | ||
InnerNotEqualArrays<T>().ToArray() switch | ||
{ | ||
var pairs => pairs.Concat(pairs.Select(pair => (pair.Y, pair.X))) | ||
}; | ||
|
||
private static IEnumerable<(T[]? X, T[]? Y)> InnerNotEqualArrays<T>() | ||
{ | ||
if (typeof(T) == typeof(string)) | ||
{ | ||
return (IEnumerable<(T[]? X, T[]? Y)>)InnerNotEqualArraysOfString(); | ||
} | ||
|
||
if (typeof(T) == typeof(int?)) | ||
{ | ||
return (IEnumerable<(T[]? X, T[]? Y)>)InnerNotEqualArraysOfInt32Nullable(); | ||
} | ||
|
||
throw new ArgumentException($"An unexpected type ({typeof(T).Name}).", nameof(T)); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...rs.Tests/CaseSources/NotEqualCaseSource_GetHashCode.InnerNotEqualArraysOfInt32Nullable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma warning disable IDE0300 // Simplify collection initialization | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
partial class NotEqualCaseSource_GetHashCode | ||
{ | ||
private static IEnumerable<(int?[]? X, int?[]? Y)> InnerNotEqualArraysOfInt32Nullable() | ||
{ | ||
yield return ( | ||
null, | ||
EmptyArray<int?>.Value); | ||
yield return ( | ||
null, | ||
new int?[] { 1 } | ||
); | ||
yield return ( | ||
EmptyArray<int?>.Value, | ||
new int?[] { 1 } | ||
); | ||
yield return ( | ||
new int?[] { 1 }, | ||
new int?[] { 1, 2 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2 }, | ||
new int?[] { 1, 2, 3 } | ||
); | ||
yield return ( | ||
new int?[] { null }, | ||
new int?[] { 1 } | ||
); | ||
yield return ( | ||
new int?[] { 1 }, | ||
new int?[] { 2 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2 }, | ||
new int?[] { 1, 1 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2, 3 }, | ||
new int?[] { 1, 0, 3 } | ||
); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...Comparers.Tests/CaseSources/NotEqualCaseSource_GetHashCode.InnerNotEqualArraysOfString.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma warning disable IDE0300 // Simplify collection initialization | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
partial class NotEqualCaseSource_GetHashCode | ||
{ | ||
private static IEnumerable<(string?[]? X, string?[]? Y)> InnerNotEqualArraysOfString() | ||
{ | ||
yield return ( | ||
null, | ||
EmptyArray<string>.Value); | ||
yield return ( | ||
null, | ||
new[] { "1" } | ||
); | ||
yield return ( | ||
EmptyArray<string>.Value, | ||
new[] { "1" } | ||
); | ||
yield return ( | ||
new[] { "1" }, | ||
new[] { "1", "2" } | ||
); | ||
yield return ( | ||
new[] { "1", "2" }, | ||
new[] { "1", "2", "3" } | ||
); | ||
yield return ( | ||
new[] { (string?)null }, | ||
new[] { "1" } | ||
); | ||
yield return ( | ||
new[] { "1" }, | ||
new[] { "2" } | ||
); | ||
yield return ( | ||
new[] { "1", "2" }, | ||
new[] { "1", "1" } | ||
); | ||
yield return ( | ||
new[] { "1", "2", "3" }, | ||
new[] { "1", "0", "3" } | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters