Ejemplo n.º 1
0
 private void AccountEquals(Account account, Account savedAccount)
 {
     Assert.AreEqual(account.EmailAddress, savedAccount.EmailAddress);
     Assert.AreEqual(account.FirstName, savedAccount.FirstName);
     Assert.AreEqual(account.LastName, savedAccount.LastName);
     Assert.AreEqual(account.Password, savedAccount.Password);
 }
Ejemplo n.º 2
0
        public void SetUp()
        {
            Init();
            _account = new Account {FirstName = "FName"};
            _userProvider = MockRepository.GenerateMock<IUserProvider>();

            _userProvider.Stub(m => m.CurrentAccount()).Return(_account);
            _accountBinder = new AccountBinder(_userProvider);
            _valueProvider.Stub(m => m.GetValue(PropertyName)).Return(new ValueProviderResult(null, null, CultureInfo.CurrentUICulture));
        }
Ejemplo n.º 3
0
 protected override void Arrange()
 {
     _account = When_retrieving_account.CreateNewAccount();
     _player = new Player
                   {
                       Account = _account,
                       Name = "test1"
                   };
     _playerRepository = new Repository<Player>(_session);
     _playerRepository.Save(_player);
 }
Ejemplo n.º 4
0
 public ActionResult Start(Account currentAccount, CreatePlayerView model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var latitude = model.BaseLatitude;
     var longitude = model.BaseLongitude;
     var player = new Player
                      {
                          Account = currentAccount,
                          Name = model.Name,
                          MainLair =
                              CreateFirstBase(model, latitude, longitude)
                      };
     _playerRepository.Save(player);
     return RedirectToAction("Index");
 }
Ejemplo n.º 5
0
        public void Arrange()
        {
            _login = new LoginModel {EmailAddress = _emailAddress, Password = _password};
            _mother = new ObjectMother();
            _account = _mother.GetAccountByEmailAddress(_emailAddress, _password);
            _currentPlayer = new Player
            {
                Account = _account,
                Name = "Player1"
            };

            _accountRepository = new InMemoryRepository<Account>(_account);
            _playerRepository = new InMemoryRepository<Player>(_currentPlayer);

            _formsService = MockRepository.GenerateMock<IFormsService>();

            _controller = new AccountController(_accountRepository, _playerRepository, _formsService);
        }
Ejemplo n.º 6
0
 public ActionResult Create(AccountCreationModel model)
 {
     if (!ModelState.IsValid)
         return View(model);
     var account = _accountRepository.Get.ByEmailAddress(model.EmailAddress);
     if (account != null && account.EmailAddress == model.EmailAddress)
     {
         //add a better message here...
         ModelState.AddModelErrorFor<AccountCreationModel, string>(m => m.EmailAddress,
                                                               "Email address already used, please specify another one.");
         return View(model);
     }
     var player = new Account
                      {
                          FirstName = model.FirstName,
                          LastName = model.LastName,
                          Password = model.Password,
                          EmailAddress = model.EmailAddress
                      };
     _accountRepository.Save(player);
     //TODO: Enable email activation
     return this.RedirectToAction<GameController>(m => m.Start());
 }
        public void SetUp()
        {
            _sessionPlayer = new Player();
            _databaseAccount = new Account {EmailAddress = "*****@*****.**"};
            _databasePlayer = new Player { Account = _databaseAccount };
            _sessionAccount = new Account();

            _httpSession = MockRepository.GenerateMock<IHttpSession>();
            _user = MockRepository.GenerateMock<IPrincipal>();
            _identity = MockRepository.GenerateMock<IIdentity>();
            _accountRepository = MockRepository.GenerateMock<IRepository<Account>>();
            _playerRepository = MockRepository.GenerateMock<IRepository<Player>>();

            _user.Stub(m => m.Identity).Return(_identity);
            _identity.Stub(m => m.Name).Return(_databaseAccount.EmailAddress);
            _accountRepository.Stub(m => m.Get).Return((new Collection<Account>{_databaseAccount}).AsQueryable());

            _userProvider = new TestUserProvider(_accountRepository, _playerRepository, _httpSession, _user);
        }
Ejemplo n.º 8
0
 public void SetUp()
 {
     var mother = new ObjectMother();
     _model = mother.GetValidAccount();
     _existingAccount = mother.GetAccountByEmailAddress(_model.EmailAddress);
     _newModel = mother.GetValidAccount();
     _newModel.EmailAddress = "*****@*****.**";
     _accountRepository = new InMemoryRepository<Account>(_existingAccount);
     _formsService = MockRepository.GenerateMock<IFormsService>();
     _playerRepository = MockRepository.GenerateMock<IRepository<Player>>();
     _controller = new AccountController(_accountRepository, _playerRepository, _formsService);
 }
Ejemplo n.º 9
0
 public void SetUp()
 {
     _mother = new ObjectMother();
     _account = _mother.GetAccountByEmailAddress("*****@*****.**");
     _playerRepository = MockRepository.GenerateMock<IRepository<Player>>();
     _areaRepository = MockRepository.GenerateMock<IRepository<Area>>();
     _mapGenerator = new MapGenerator();
     _controller = new GameController(_playerRepository, _areaRepository, _mapGenerator);
     _view = new CreatePlayerView
                      {
                          Name = "Dr. Evil",
                          BaseName = "My Base",
                          BaseLatitude = _latitude,
                          BaseLongitude = _longitude
                      };
 }
Ejemplo n.º 10
0
 public static Player CurrentPlayerFor(this IQueryable<Player> query, Account account)
 {
     return query.FirstOrDefault(m => m.Account.Id == account.Id);
 }