The function I want to test returns an int[][] aaiCluster1
with data
aaiCluster1[0] = int[] { 1, 2 }
aaiCluster1[1] = int[] { 0 }
so I test using
CollectionAssert.AreEqual (aaiCluster1[0], new int[] { 1, 2 });
CollectionAssert.AreEqual (aaiCluster1[1], new int[] { 0 });
But the order of the int[]
is not important and may change, so I rather want to test
CollectionAssert.Contains (aaiCluster1, new int[] { 1, 2 });
but this fails.
Is this command not able to evaluate the content of the array?
Any ideas for a suitable workaround, that does not require additional helper functions?
edit
I have to clarify:
it's about testing whether a jagged array contains another simple array nested in it.
What else must I explain??
edit #2
2 answers suggesting CollectionAssert.AreEquivalent
were given already and have been deleted again, because AreEquivalent
is not what I'm looking for... it does not work here.
1 answer suggesting Sequence.whatever
was given, and it's even more wrong.
edit #3
I reverted Igor's changes to my question, because I feel they too much alter the meaning. However, I think his words are a good alternative describtion, so here is his text:
So I test using
CollectionAssert.AreEqual(new int[] { 1, 2 }, aaiCluster1[0]);
CollectionAssert.AreEqual(new int[] { 0 }, aaiCluster1[1]);
But the order in aaiCluster1
(actual) is not known so the above tests could fail as soon as the returned order in aaiCluster1
changes.
Question
How can I call something similar to this
CollectionAssert.AreEqual(new int[] { 1, 2 }, aaiCluster1);
// CollectionAssert.AreEqual(ICollection<T> expected, ICollection<ICollection<T>> actual);
where all arrays in aaiCluster1
are evaluated against the expected parameter new int[] { 1, 2 }
and the assert passes if there is at least one contained array that is found to be Equal to the expected?