public ValidApplicationReceived()
 {
     _registrator = new Registrator();
     var app = new Application(email:"*****@*****.**",password:"******",confirm:"password");
     _result = _registrator.ApplyForMembership(app);
     _user = _result.NewUser;
 }
 public ValidApplicationReceived()
     : base()
 {
     _reg = new Registrator();
       var app = new Application(email:"*****@*****.**",password:"******",confirm:"password");
       _result = _reg.ApplyForMembership(app);
       _user = _result.NewUser;
 }
 public PasswordMistmatch()
 {
     var app = new Application("*****@*****.**", "password", "something else");
       _result = new Registrator().ApplyForMembership(app);
 }
 public void ApplicationReturnsMessage()
 {
     var app2 = new Application("*****@*****.**", "password", "password");
       _result = new Registrator().ApplyForMembership(app2);
       Assert.Contains("exists", _result.Application.UserMessage);
 }
 public void ApplicationIsInvalid()
 {
     var app2 = new Application("*****@*****.**", "password", "password");
       _result = new Registrator().ApplyForMembership(app2);
       Assert.True(app2.IsInvalid());
 }
 public void AppDoesntThrow()
 {
     var app2 = new Application("*****@*****.**", "password", "password");
       Assert.DoesNotThrow(() => _result = new Registrator().ApplyForMembership(app2));
 }
 public ExistingEmail()
     : base()
 {
     var app1 = new Application("*****@*****.**", "password", "password");
       _result = new Registrator().ApplyForMembership(app1);
 }
 public ShortPassword()
 {
     var app = new Application("*****@*****.**", "pass", "pass");
       _result = new Registrator().ApplyForMembership(app);
 }
 public ShortEmail()
 {
     var app = new Application("rob@b", "password", "password");
       _result = new Registrator().ApplyForMembership(app);
 }
Esempio n. 10
0
        public RegistrationResult ApplyForMembership(Application app)
        {
            var result = new RegistrationResult();

              CurrentApplication = app;
              result.Application = app;
              result.Application.UserMessage = "Welcome!";

              if (EmailOrPasswordNotPresent())
            return InvalidApplication(Properties.Resources.EmailOrPasswordMissing);

              if (EmailIsInvalid())
            return InvalidApplication(Properties.Resources.InvalidEmailMessage);

              if (PasswordIsInvalid())
            return InvalidApplication(Properties.Resources.InvalidPassword);

              if (PasswordDoesNotMatchConfirmation())
            return InvalidApplication(Properties.Resources.PasswordConfirmationMismatch);

              if (EmailAlreadyRegistered())
            return InvalidApplication(Properties.Resources.EmailExists);

              //Accept the application
              result.NewUser = AcceptApplication();

              //log them in
              var auth = new Authenticator().AuthenticateUser(new Credentials { Email = result.NewUser.Email, Password = CurrentApplication.Password });
              result.SessionToken = auth.Session.ID;

              return result;
        }
Esempio n. 11
0
 public RegistrationResult InvalidApplication(string reason)
 {
     var result = new RegistrationResult();
       CurrentApplication.Status = ApplicationStatus.Invalid;
       result.Application = CurrentApplication;
       result.Application.UserMessage = reason;
       return result;
 }
 public EmptyEmailOrPassword()
 {
     var reg = new Registrator();
       _result = reg.ApplyForMembership(new Application("","password",""));
 }