public void Setup()
 {
     user = new User() { Id = guid, UserName = "******", Password = "******" };
       persistor = new Mock<IPersistor>();
       persistor.Setup(x => x.GetById<User>(guid)).Returns(user);
 }
 private IridioMembershipUser GetUserFromMembershipUser(User membershipUser)
 {
     return new IridioMembershipUser(this.Name,
                           membershipUser.UserName,
                           membershipUser.Id,
                           membershipUser.Email,
                           membershipUser.PasswordQuestion,
                           membershipUser.Comment,
                           membershipUser.IsApproved,
                           membershipUser.IsLockedOut,
                           membershipUser.CreationDate ?? new DateTime(),
                           membershipUser.LastLoginDate ?? new DateTime(),
                           membershipUser.LastActivityDate ?? new DateTime(),
                           membershipUser.LastPasswordChangedDate ?? new DateTime(),
                           membershipUser.LastLockedOutDate ?? new DateTime(),
                           membershipUser.Profile);
 }
 public void Create_Initialize_Profile()
 {
     User user = new User();
       Assert.IsNotNull(user.Profile);
 }
 public bool SendRegisterCongratulationsToEmail(User user)
 {
     return emailService.Send(user.Email, Resources.Email.RegisterCongratulationsSubject, Resources.Email.RegisterCongratulationsBody, true);
 }
        public static Mock<IUsersRepository> GetMockUsersRepository(string appName)
        {
            var goodUser = new User()
              {
            Id = Guid1,
            Password = "******",
            IsApproved = true,
            CreationDate = DateTime.Now,
            PasswordAnswer = "GoodAnswer",
            LastLockedOutDate = DateTime.Now,
            LastPasswordChangedDate = DateTime.Now,
            LastLoginDate = DateTime.Now,
            UserName = "******"
              };

              var mockRepo = new Mock<IUsersRepository>();
              mockRepo.Setup(v => v.GetUserByName("GoodUser", appName)).Returns(goodUser);
              mockRepo.Setup(v => v.GetUserByName("LockedUser", appName)).Returns(new User() { IsLockedOut = true });
              mockRepo.Setup(v => v.GetUserByName("BadAnswerUser", appName)).Returns(new User() { PasswordAnswer = "GoodAnswer", Password = "******" });
              mockRepo.Setup(v => v.GetUserByName("PasswordAttemptCount5", appName)).Returns(new User() { Id = Utilities.Guid3, FailedPasswordAttemptCount = 5 });
              mockRepo.Setup(v => v.GetUserByName("PasswordAttemptCount4", appName)).Returns(new User() { Id = Utilities.Guid3, FailedPasswordAttemptCount = 4 });
              mockRepo.Setup(v => v.GetUserByName("PasswordAnswerAttemptCount5", appName)).Returns(new User() { Id = Utilities.Guid3, FailedPasswordAnswerAttemptCount = 5 });
              mockRepo.Setup(v => v.GetUserByName("PasswordAnswerAttemptCount4", appName)).Returns(new User() { Id = Utilities.Guid3, FailedPasswordAnswerAttemptCount = 4 });
              mockRepo.Setup(v => v.GetUserByName("EncryptUser", appName)).Returns(new User() { PasswordAnswer = "SerLEVf28XZ/mBLKLgqulBDfUK05rOsefCL0gd+WRDE=", Password = "******", IsApproved = true });
              mockRepo.Setup(v => v.GetUserByName("HashUser", appName)).Returns(new User() { PasswordAnswer = "/jGKx1DvdLPnZk1ZuQaz2fSFdws=", Password = "******", IsApproved = true });
              mockRepo.Setup(v => v.GetUserByName("NewUser", appName)).Returns((User)null);
              mockRepo.Setup(v => v.GetUserByName("ExceptionUser", appName)).Throws(new Exception());
              mockRepo.Setup(v => v.GetBy(Guid1)).Returns(goodUser);
              mockRepo.Setup(v => v.GetBy(Guid999)).Throws(new Exception()); //Serve per simulare eccezione eventuale nel get del repository
              mockRepo.Setup(v => v.FindUsersByEmail("GoodEmail", 0, 99, appName)).Returns(GetStubUsers(1));
              mockRepo.Setup(v => v.FindUsersByEmail("BadEmail", 0, 99, appName)).Returns(new List<User>());
              mockRepo.Setup(v => v.FindUsersByEmail("DupEmail", 0, 99, appName)).Returns(GetStubUsers(2));
              mockRepo.Setup(v => v.FindUsersByEmail("ExceptionMail", 0, 99, appName)).Throws(new Exception());
              mockRepo.Setup(v => v.FindUsersByName("GoodName", 0, 99, appName)).Returns(GetStubUsers(1));
              mockRepo.Setup(v => v.FindUsersByName("BadName", 0, 99, appName)).Returns(new List<User>());
              mockRepo.Setup(v => v.FindUsersByName("DupName", 0, 99, appName)).Returns(GetStubUsers(2));
              mockRepo.Setup(v => v.FindUsersByName("ExceptionUser", 0, 99, appName)).Throws(new Exception());
              mockRepo.Setup(v => v.GetUserNameByEmail("NewEmail", appName)).Returns("");
              mockRepo.Setup(v => v.GetUserNameByEmail("DupEmail", appName)).Returns("DupUser");
              mockRepo.Setup(v => v.GetUserNameByEmail("ExceptionEmail", appName)).Throws(new Exception());
              int totale = 10;
              mockRepo.Setup(v => v.GetUsers(0, 99, appName, out totale)).Returns(GetStubUsers(2));
              mockRepo.Setup(v => v.GetUsers(1, 99, appName, out totale)).Returns(new List<User>());
              mockRepo.Setup(v => v.GetUsers(2, 99, appName, out totale)).Throws(new Exception());

              var users = new List<User>() {
            new User() {Id = Guid1, UserName = "******" },
            new User() {Id = Guid2, UserName = "******" },
            new User() {Id = Guid3, UserName = "******" },
            new User() {Id = Guid4, UserName = "******" },
              };
              return mockRepo;
        }