0
        var input = new char[9][] {new char[9]...}
        var expected = new char[27][] {new char[9]...}
        var result = SudokuLibrary.BoardOrganizer.BoardOrganizerSolution(input);

I don't understand why the test fails when I test it with

        CollectionAssert.AreEqual(expected, result);

But doesn't fail when I loop through the jagged arrays to compare each element.

        var test = true;
        for(int i = 0; i < 27; i++)
        {
            for(int j = 0; j < 9; j++)
            {
                if (result[i][j] != expected[i][j])
                    test = false;
            }
        }
        Assert.AreEqual(true, test);

There information about this online, but I don't understand it well. If every character in both jagged arrays are the same and in the same order, why does CollectionsAssert.AreEqual say that the jagged arrays aren't equal?

  • 1
    have you made sure two collections `dimensions` and `length` are the same? i suggest you unit test the assertion method itself first using some **hardcoded shorter** array. – Lei Yang Jan 13 '22 at 01:58
  • One duplicate explains your "why code that compares elements compares elements when code that does not compare elements does not compare elements" question, the [other one](https://stackoverflow.com/questions/4185164/recursive-assert-on-collection) gives you examples of how to write one. If those two not enough for you to as an answer please [edit] the question to include explanation how those two did not help and what exactly you don't understand. – Alexei Levenkov Jan 13 '22 at 02:27

0 Answers0