I need to develop a fairly simple algorithm, but I'm confused about how best to write a test for it.
General description: The user should be able to delete the plan. The plan has tasks associated with it, they must also be deleted (while they have not yet been completed).
Pseudo-code how the algorithm should behave:
PlanController.DeletePlan(plan)
=>
PlanDbRepository.DeletePlan()
ForEach Task t in plan.Tasks
If t.Status = Status.Open Then
TaskDbRepository.DeleteTask(t)
End If
End ForEach
Now, as I understand it, unit tests should not concern the database or generally require access to any external systems, so I assume that I have two options:
1) Retrieve the repository calls and check if they have been called the appropriate number of times, like “Claims”
2) Create stubs for both repository classes by manually setting the delete flag, and then make sure the corresponding objects are marked for deletion.
: ? EXTRA, ?
. - , RhinoMocks. , .