Hi,
Disclaimer: This is my first time writing unit tests...be gentle! :)
I am trying to write a test for the following method and would like people's thoughts an whether I am thinking about this the correct way. I have an interface called IAuthenticationProvider with the following method:
bool Authenticate(string username, string password)
I also have a class called UserAccountService that has the following method:
bool SignIn(string username, string password)
The UserAccountService takes a IAuthenticationProvider interface as part of the constructor and is used within the SignIn method. The SignIn method looks a little like:
public bool SignIn(string username, string password)
{
// _provider is of type IAuthenticationProvider
bool result = _provider.Authenticate( username, password );
// ....
return result;
}
Initially when I thought of tests such as "signing in with unknown username", "signing in with an invalid password", etc. But, I then began to think that I don't really want to test the "authentication" aspect, i.e. _provider.Authenticate, but I want to test the actual signing in. So, I thought tests such as "signining in while already signed in", "signing in when the user cannot be authenticated", etc, would make more sense.
Would this be the right way of approaching this these type of tests?
Kind Regards
Michael