Created
March 4, 2010 18:49
-
-
Save ignu/322013 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class WebServiceTest | |
{ | |
[Test] | |
public void should_call_authentication_service() | |
{ | |
service.MyMethod(); | |
Verify<IAuthenticationService>(a => a.Authenticate(username, password)).WasCalled(); | |
} | |
} | |
[TestFixture] | |
public class AuthenticationServiceTest | |
{ | |
[Test] | |
[ExpectedException(typeof(UnauthorizedAccessException))] | |
public void should_throw_when_user_not_found() | |
{ | |
Mock<IUserRepository>().Expect(u => u.FindByUserName("i")).Returns(null); | |
authenticationService.Authenticate("i", "notMyPassword"); | |
} | |
[Test] | |
[ExpectedException(typeof(UnauthorizedAccessException))] | |
public void should_throw_when_invalid_password() | |
{ | |
Mock<IUserRepository>().Expect(u => u.FindByUserName("i")).Returns(new User("i", "password")); | |
authenticationService.Authenticate("i", "notMyPassword"); | |
} | |
[Test] | |
public void should_return_true_when_valid_password() | |
{ | |
Mock<IUserRepository>().Expect(u => u.FindByUserName("i")).Returns(new User("i", "password")); | |
authenticationService.Authenticate("i", "password").ShouldBeTrue(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment