Skip to content
Discussion options

You must be logged in to vote

@LPenny-github

你好 😊

Xunit 支援「比對 IEnumerable<T> 」 ( https://github.com/xunit/assert.xunit/blob/2.4.1/CollectionAsserts.cs#L293 )

        public static void Equal<T>(IEnumerable<T> expected, IEnumerable<T> actual)

https://github.com/xunit/assert.xunit/blob/2.4.1/CollectionAsserts.cs#L306

        public static void Equal<T>(IEnumerable<T> expected, IEnumerable<T> actual, IEqualityComparer<T> comparer)

以下程式碼我沒有實際測試過,然而,以 LeetCodeExample1() 為例,應該可以改成

class IntervalComparer : IEqualityComparer<int[]>
{
  public bool Equals(int[] i1, int[] i2) =>
    i1 != null
    && i2 != null
    && i1.Length == 2
    && i2.Length == 2
    && i1[0] == i2[0]
    && i1[1] == i2[1];

  public int GetHashCode(i…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@LPenny-github
Comment options

Answer selected by LPenny-github
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants