I have a method that returns:
Map<String, List<Account>> results
I want to have a test class that asserts that the map contains two list records with one string value. I can't figure out how to do the assertion. I know that with a debug that there are two records in the list.
I tried this:
List<Account> outerList = results.values();
System.assertEquals(2, outerList.size());
and I get the error:
Illegal assignment from List<List<Account>> to List<Account>
I tried this:
System.assertEquals(2, results.values().size());
and I get the result:
Assertion Failed: Expected: 2, Actual: 1
I tried this:
System.assertEquals(2, results.size());
and I get the result:
Assertion Failed: Expected: 2, Actual: 1
What am I doing wrong?
Best Answer
There's only one key, with two elements, so you'd do: