public static void AssertRefAnyOrderArr(Object[][] expected, Object[][] received) { // Empty lists are fine if (((received == null) && (expected == null)) || ((received.Length == 0) && (expected == null)) || ((received == null) && (expected.Length == 0))) { return; } // Same number Assert.AreEqual(expected.Length, received.Length); // For each expected object find a received object int numMatches = 0; var foundReceived = new bool[received.Length]; foreach (var expectedArr in expected) { bool found = false; for (int i = 0; i < received.Length; i++) { // Ignore found received objects if (foundReceived[i]) { continue; } bool match = ArrayCompareUtil.CompareRefExactOrder(received[i], expectedArr); if (match) { found = true; numMatches++; // Blank out received object so as to not match again foundReceived[i] = true; break; } } if (!found) { Log.Error(".assertEqualsAnyOrder Not found in received results is expected=" + expectedArr.Render()); for (int j = 0; j < received.Length; j++) { Log.Error(".assertEqualsAnyOrder received (" + j + "):" + received[j].Render()); } Assert.Fail(); } } // Must have matched exactly the number of objects times Assert.AreEqual(numMatches, expected.Length); }
public static void AssertEqualsAnyOrder(EventBean[][] expected, EventBean[][] received) { // Empty lists are fine if (received.IsEmptyOrNull() && expected.IsEmptyOrNull()) { return; } // Same number Assert.AreEqual(expected.Length, received.Length); // For each expected object find a received object int numMatches = 0; var foundReceived = new bool[received.Length]; foreach (var expectedObject in expected) { bool found = false; for (int i = 0; i < received.Length; i++) { // Ignore found received objects if (foundReceived[i]) { continue; } bool match = ArrayCompareUtil.CompareEqualsExactOrder(received[i], expectedObject); if (match) { found = true; numMatches++; foundReceived[i] = true; break; } } if (!found) { Log.Error(".assertEqualsAnyOrder Not found in received results is expected=" + expectedObject.Render()); Log.Error(".assertEqualsAnyOrder received=" + received.Render()); } Assert.IsTrue(found); } // Must have matched exactly the number of objects times Assert.AreEqual(numMatches, expected.Length); }