The current unit test for LastWeek() :
[Fact]
[Task(1)]
public void Last_week()
{
Assert.Equal(new int[] { 0, 2, 5, 3, 7, 8, 4 }, BirdCount.LastWeek());
}
This is a static call, which is inconsistent with most of the API. I suggest changing it to non-static
otherwise birdsPerDay would have to be static, which would break many of the other methods.
Example fix:
[Fact]
[Task(1)]
public void Last_week()
{
var counts
Why would birdsPerDay need to be static as well? That’s not part of the test in question and isn’t related to LastWeek(). Changing either bit would break thousands of existing solutions so we should tread carefully. How would either change help a student practice arrays and loops, the associated concepts?
1 Like
After giving this Too Much Thought…the data has to come from somewhere. There is only one solution that passes the unit test:
public static int LastWeek()
{
return new int { 0, 2, 5, 3, 7, 8, 4 };
}
So basically hard coding the values to pass the unit test. So basically the task isn’t reasonable, because it requires you to know the values to write the function, so that you can call the function to get the values.
This. Is. Kaka.
Did you read the instructions? The instructions say,
For comparison purposes, you always keep a copy of last week’s counts nearby, which were: 0, 2, 5, 3, 7, 8 and 4. Implement the (static) BirdCount.LastWeek() method that returns last week’s counts
Yes, of course I read the instructions, but I just really couldn’t believe the insanity of it. It might as well have said “Here, return exactly this array which has no resemblance to any real world use whatsoever”. In real life, this is exactly the sort of thing you would NOT do; it is the epitome of baaad design 
I suppose my thirty years as an embattled software engineer was actually a disadvantage here, oddly enough.
You can skip the concept exercises and go straight to the practice exercises. Those are much less contrived. It’s hard to write exercises that practice a specific concept that don’t feel contrived.
Fair enough, although for something this basic it probably should have just been left out.
It might seem basic to you but if you’ve never done something like this before, it might not seem so basic!
The exercises try to cover the skill range from zero to pro.
1 Like