xUnit general repository testing of add, update, delete
Is it worth unit testing the repository add, update or delete methods, please?
public void Update(TEntity entity)
{
dbSet.Update(entity);
}
and usage:
UnitOfWork.NeakReports.Update(neakReport);
I ask because everything is moqed so I do not know if it is a must then how.
You can think about unit testing as a safety net.
So, the answer highly depends on what sort of safety net do you want to have, like:
- do not alter the input rather pass it as it is to the underlying component
- wrapper calls the right method (wrapper's
Update
should not call wrapped'sDelete
) - wrapper calls only the expected method on the dependency and nothing else ...
In other words if there is a chance in the future that this thin wrapper become thicker then you want to make sure it happens by breaking some test(s). If a code can sneak in without notice then it can cause harm.
Your level of paranoia will determine how much test is enough :)