[Solved] Unit Testing with ForEach [closed]


There is probably a lot you could do, but the first thing to do would be to make it more readable. Perhaps something like this:

var nullActivities = 
  from p in partnerList
  from t in p.Tenants
  let activity = agent.GetShopActivity(t, startDate, endDate)
  where activity == null
  select activity;

Assert.Empty(nullActivities);

Moreover:

you may want to think about

  • a test should be simple (i.e. it should have a Cyclomatic Complexity of 1).
  • it should be immediately evident to a person reading the test what scenario and behaviour is being tested (in case the values of startDate and endDate are significant it might be beneficial to give them less generic names).
  • prefer having only a single assertion as that makes it easy to know where the test failed when it fails.

3

solved Unit Testing with ForEach [closed]