I have 2 dictionaries, and I expect the content to not be equivalent, since the dictionary contains values of different types. However, the next test passes
[Scenario]
public void DictionariesWithDifferentTypesShouldBeEquivalent(
Dictionary<string, object> firstDictionary,
Dictionary<string, object> secondDictionary)
{
"Given a dictionary"
.f(() => firstDictionary = new Dictionary<string, object>
{
{ "latency", 0 },
{ "errorMessages", new string[0] },
{ "lastChanged", new DateTime(635272310930829706) },
{ "query", new string[0] },
{ "items", new string[] { "foo", "bar" } },
{ "name", "Bob" },
{ "number", 3 },
{ "updateInterval", 10 },
});
"And a second dictionary with same values but of differing types"
.f(() => secondDictionary = new Dictionary<string, object>
{
{ "latency", 0L },
{ "errorMessages", new object[0] },
{ "lastChanged", new DateTime(635272310930829706) },
{ "query", new string[0] },
{ "items", new string[] { "bar", "foo" } },
{ "name", "Bob" },
{ "number", 3 },
{ "updateInterval", "10" },
});
"When I check for equivalency"
.f(() => { });
"Then the dictionaries should be equivalent"
.f(() => firstDictionary.ShouldBeEquivalentTo(secondDictionary));
}
If this is the expected behavior, how can I set up a free claims rule to check if the type matches?
I explored the use of both MatchingRule and AssertionRule, but in both cases I don't seem to have access to the original object types and expected ones. Apparently, the object has already been converted to the expected type. Ie in exapmle above updateInterval in the first dictionary would already be converted to a string for comparison with the second dictionary.
Thanks for the help,
Rachel