DefconDotNet

Untitled

Feb 20th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1.  
  2.             [Fact]
  3.             public void WithValidUsernamePasswordReturnsTrue()
  4.             {
  5.                 // Arrange
  6.                 var user = new Freelancer { Id = 1, Active = true, Username = "Username", PasswordHash = "ThisIsThePasswordHash" };
  7.                 var securityServiceMock = new Mock<ISecurityService>();
  8.                 securityServiceMock.Setup(a => a.ComputeHash("Password", 1)).Returns(() => "ThisIsThePasswordHash");
  9.                 var userServiceMock = new Mock<IUserService>();
  10.                 userServiceMock.Setup(a => a.GetUser("Username")).Returns(() => user);
  11.  
  12.                 // Act
  13.                 var authenticationService = new AuthenticationService(securityServiceMock.Object, userServiceMock.Object);
  14.                 var isAuthenticated = authenticationService.Authenticate("Username", "Password");
  15.  
  16.                 // Assert
  17.                 Assert.True(isAuthenticated);
  18.             }
Advertisement
Add Comment
Please, Sign In to add comment