I have an interface method whose signature is as follows:
void SetValues(IDictionary<string, object> the_values);
I have a client class that uses that method. I want The unit test for that class to verify that, in a particular case, a specific key and value pair are passed in. Right now, if I want to express that I'm expecting the SetValues
method to be called with the single key-value pair { "Date", DateTime(1972,1,2) } I write the following:
item.Expect(i => i.SetValues(
Arg<IDictionary<string, object>>.Matches(
(items) => (items.Count() == 1 &&
items.First().Key == "Date" &&
(DateTime) items.First().Value == new DateTime(1972,1,2))));
The expectation seems to work, but my does that look ugly. Is there a better way to express expectations about the contents of a collection being passed in as a parameter?