public void CanGetUserAPI() { var userRepo = new Mock<IUserRepository>(MockBehavior.Strict); var user = new User {UserName = "******", Password = "******",APIKey = "jawn"}; userRepo.Setup(e => e.GetAPIKey(user.UserName, user.Password)).Returns(user.APIKey); var apiKey = new CharcoalMembershipProvider(userRepo.Object).GetPassword(user.UserName,user.Password); Assert.AreEqual(user.APIKey, apiKey); userRepo.Verify(); }
public void CanGetUserByEmail() { const string myMail = "*****@*****.**"; var userRepo = new Mock<IUserRepository>(MockBehavior.Strict); const string userName = "******"; userRepo.Setup(e => e.FindByEmail(myMail)).Returns(new User { UserName = userName }); var retirevedUserName = new CharcoalMembershipProvider(userRepo.Object).GetUserNameByEmail(myMail); Assert.AreEqual(userName, retirevedUserName); userRepo.Verify(); }
public void CanValidateUserExistence() { var userRepo = new Mock<IUserRepository>(MockBehavior.Strict); const string userName = "******"; const string password = "******"; userRepo.Setup(e => e.IsValid(userName, password)).Returns(true); var isValid = new CharcoalMembershipProvider(userRepo.Object) .ValidateUser(userName,password); Assert.IsTrue(isValid); userRepo.Verify(); }