I have this method in ContractClass
:
public UserModel GetUser(string groupName, string login) {
Contract.Requires(groupName != null);
Contract.Requires(groupName != string.Empty);
Contract.Requires(login != null);
Contract.Requires(login != string.Empty);
return default(UserModel);
}
How would you test this? Do you test all combinations of all possible scenarios when contract fails (ex: groupName
is empty and login
is null ... and so on)?
Yes, otherwise
E.g.: If you only test that it fails when groupName
is equal to null
and login
is equal to null
, and your test fails - you can not be sure that it fails for the correct condition. And what's even more important: You can not even be sure that you have all the correct and important calls to Contract.Requires
.