How to verify contents of IEnumerable Collection
First off do not reply to just say to use Is.EquivalentTo. That does not work for the case I am asking here.
I have a class that has a property that I want to verify in nUnit. That property is declared as an IEnumerable for some interface type. e.g IEnumerable<
The interface itself has a number of properties defined in the interface.
I want to verify the items that property returns based on those properties. The order of the IEnumerable does not matter.
So if for example if I had:
public interface ISomeInterface
{
string Property1 { get; }
string Property2 { get; }
string Property3 { get; }
}
This would is a simple thing to verify using FitNesse and a RowFixture. I just do:
|use|property|
|Property1|
| a | b | c |
| d | e | f |
But I cannot find a clean way to do this with nUnit. The only way I have come up with is:
This would not work if I wanted to verify that it has multiple of the same values.
IsEquivalentTo seems to be the thing I should be using, but it would not work. It works for collections of simple value types. It ends up trying to use Object.equals between a constraint and the actual instance of ISomeInterface.
Note that the testing code has no access to any concrete implementations of ISomeInterface so there is nothing to create to check equality with. The concrete implementations do not even have setters for the properties. The properties are all generated from other data, which is part of what I am trying to test.
So what I really need is some equivalent to a FitNesse RowFixture.
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- NUnit V2 Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Dale King for more information if necessary.