public void CreateStatement_ExpectValid()
        {
            //Arrange
            string localStatementIdString = "STMT01";
            StatementId localStatementId = new StatementId(localStatementIdString);

            SpecificFieldsFactory localfactory = new SpecificFieldsFactory();
            string[] listspecificfields = { "Credit Card", "12" };
            StatementType localStatementType = new StatementType(localfactory, "CreditCardProvider", listspecificfields);

            StatementSpecificFields localspecificfields = localStatementType.getSpecificFields();

            int localstatementAccountnumber = 1234567;
            string localstatementAccountholdername = "Bruce";
            DateTime localstatementDate = DateTime.Now;
            StatementCommonFields localStatementCommonFields = new StatementCommonFields(localstatementAccountnumber, localstatementAccountholdername, localstatementDate);

            APSUser localAPSUser = new APSUser(new APSUserId("1"), "testusername", "testpassword");
            BillingAccount localBillingAccount = new BillingAccount(new BillingAccountId("1"), new BillingCompanyId("1"), "testusername", "testpassword", localAPSUser);

            //Act
            Statement localStatement = new Statement(localStatementId, localStatementCommonFields, localStatementType, localspecificfields, localAPSUser, localBillingAccount);

            //Assert
            Assert.AreEqual(localStatement.StatementId, localStatementId);
            Assert.AreEqual(localStatement.StatementCommonFields, localStatementCommonFields);
            Assert.AreEqual(localStatement.StatementType, localStatementType);
            Assert.AreEqual(localStatement.StatementSpecificFields, localspecificfields);
            Assert.AreEqual(localStatement.APSUser, localAPSUser);
            Assert.AreEqual(localStatement.BillingAccount, localBillingAccount);
        }
Exemplo n.º 2
0
        public void CreateStatement_ExpectValid()
        {
            //Arrange
            string      localStatementIdString = "STMT01";
            StatementId localStatementId       = new StatementId(localStatementIdString);

            SpecificFieldsFactory localfactory = new SpecificFieldsFactory();

            string[]      listspecificfields = { "Credit Card", "12" };
            StatementType localStatementType = new StatementType(localfactory, "CreditCardProvider", listspecificfields);

            StatementSpecificFields localspecificfields = localStatementType.getSpecificFields();


            int      localstatementAccountnumber     = 1234567;
            string   localstatementAccountholdername = "Bruce";
            DateTime localstatementDate = DateTime.Now;
            StatementCommonFields localStatementCommonFields = new StatementCommonFields(localstatementAccountnumber, localstatementAccountholdername, localstatementDate);

            APSUser        localAPSUser        = new APSUser(new APSUserId("1"), "testusername", "testpassword");
            BillingAccount localBillingAccount = new BillingAccount(new BillingAccountId("1"), new BillingCompanyId("1"), "testusername", "testpassword", localAPSUser);

            //Act
            Statement localStatement = new Statement(localStatementId, localStatementCommonFields, localStatementType, localspecificfields, localAPSUser, localBillingAccount);

            //Assert
            Assert.AreEqual(localStatement.StatementId, localStatementId);
            Assert.AreEqual(localStatement.StatementCommonFields, localStatementCommonFields);
            Assert.AreEqual(localStatement.StatementType, localStatementType);
            Assert.AreEqual(localStatement.StatementSpecificFields, localspecificfields);
            Assert.AreEqual(localStatement.APSUser, localAPSUser);
            Assert.AreEqual(localStatement.BillingAccount, localBillingAccount);
        }
        public ActionResult Manage(ManageUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                APSUser user = AccountsRepo.GetUserAccountByUserID(FakeData.UserID);
                AccountsRepo.UpdateAPSUser(user);
                return(RedirectToAction("Index", "Home"));
            }

            return(View());
        }
 public bool InsertAPSUser(APSUser user)
 {
     try
     {
         FakeData.Users.Add(user);
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 5
0
 public bool InsertAPSUser(APSUser user)
 {
     try
     {
         FakeData.Users.Add(user);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public void Get_APSUser_ExpectCorrectUserReturned()
        {
            var repository = MockRepository.GenerateMock<IAPSUserRepository>();
            string localAPSUserIdString = "APS01";
            string localAPSUserName = "******";
            string localAPSPassword = "******";
            APSUserId localAPSUserId = new APSUserId(localAPSUserIdString);
            APSUser localAPSUser = new APSUser(localAPSUserId,localAPSUserName,localAPSPassword);

            var temp = repository.Stub(r => r.GetAPSUserById(localAPSUserId)).Equals(localAPSUser);

            repository.VerifyAllExpectations();
        }
Exemplo n.º 7
0
        public void Get_APSUser_ExpectCorrectUserReturned()
        {
            var       repository           = MockRepository.GenerateMock <IAPSUserRepository>();
            string    localAPSUserIdString = "APS01";
            string    localAPSUserName     = "******";
            string    localAPSPassword     = "******";
            APSUserId localAPSUserId       = new APSUserId(localAPSUserIdString);
            APSUser   localAPSUser         = new APSUser(localAPSUserId, localAPSUserName, localAPSPassword);

            var temp = repository.Stub(r => r.GetAPSUserById(localAPSUserId)).Equals(localAPSUser);

            repository.VerifyAllExpectations();
        }
Exemplo n.º 8
0
        public ActionResult Link(LinkBillingAccountViewModel Model)
        {
            if (ModelState.IsValid)
            {
                APSUser        MyUser = AccountRepo.GetUserAccountByUserID(FakeData.UserID);
                BillingAccount BA     = new BillingAccount(new BillingAccountId(Guid.NewGuid().ToString()), new BillingCompanyId(Model.CompanyID), Model.Username, Model.Password, MyUser);
                BillingAccountRepo.InsertBillingAccount(BA);
                return(RedirectToAction("Index"));
            }

            ViewBag.CompanyID = new SelectList(FakeData.BillingCompanies, "BillingCompanyId.IdString", "CompanyName");
            return(View(Model));
        }
        public ActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                APSUser user = new APSUser(new APSUserId(Guid.NewGuid().ToString()), model.Username, model.Password);
                AccountsRepo.InsertAPSUser(user);

                FormsAuthentication.SetAuthCookie(user.APSUsername, false);
                FakeData.UserID = user.APSUserId.IdString;
                return(RedirectToAction("Index", "Home"));
            }

            return(View());
        }
        public bool UpdateAPSUser(APSUser user)
        {
            try
            {
                int index = FakeData.Users.FindIndex(x => x.APSUserId.IdString == user.APSUserId.IdString);
                FakeData.Users[index] = user;

                return true;
            }
            catch
            {
                return false;
            }
        }
Exemplo n.º 11
0
        public bool UpdateAPSUser(APSUser user)
        {
            try
            {
                int index = FakeData.Users.FindIndex(x => x.APSUserId.IdString == user.APSUserId.IdString);
                FakeData.Users[index] = user;

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 12
0
        public void Create_NewAPSUSer_ExpectValid()
        {
            //Arrange
            string    localAPSUserIdString = "APS01";
            string    localUsername        = "******";
            string    localPassword        = "******";
            APSUserId localAPSUserId       = new APSUserId(localAPSUserIdString);

            //Act
            APSUser localAPSUser = new APSUser(localAPSUserId, localUsername, localPassword);

            //Assert
            Assert.AreEqual(localAPSUser.APSUserId, localAPSUserId);
            Assert.AreEqual(localAPSUser.APSUsername, localUsername);
            Assert.AreEqual(localAPSUser.APSPassword, localPassword);
        }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="APSUser"/> class.
 /// </summary>
 /// <param name="StatementId">Statement identifier.</param>
 /// <param name="StatementCommonFields">Common field for all statements.</param>
 /// <param name="StatementType">Identifies the what type for statements this is</param>
 /// <param name="SpecificFields">Specific Fields allocated to statement based on  statement type</param>
 /// <exception cref="System.ArgumentNullException"></exception>
 public Statement(StatementId statementId, StatementCommonFields statementCommonFields, StatementType statementType, StatementSpecificFields statementSpecificFields, APSUser apsuser, BillingAccount billingAccount)
 {
     if (statementId != null && statementCommonFields != null && statementType != null && statementSpecificFields != null && apsuser != null && billingAccount != null)
     {
         this._statementId             = statementId;
         this._statementCommonFields   = statementCommonFields;
         this._statementType           = statementType;
         this._statementSpecificFields = statementSpecificFields;
         this._apsuser        = apsuser;
         this._billingAccount = billingAccount;
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
Exemplo n.º 14
0
        public void Create_NewAPSUSer_ExpectValid()
        {
            //Arrange
            string localAPSUserIdString = "APS01";
            string localUsername = "******";
            string localPassword = "******";
            APSUserId localAPSUserId = new APSUserId(localAPSUserIdString);

            //Act
            APSUser localAPSUser = new APSUser(localAPSUserId, localUsername, localPassword);

            //Assert
            Assert.AreEqual(localAPSUser.APSUserId, localAPSUserId);
            Assert.AreEqual(localAPSUser.APSUsername, localUsername);
            Assert.AreEqual(localAPSUser.APSPassword, localPassword);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BillingAccount"/> class.
 /// </summary>
 /// <param name="billingAccountId">The billing account identifier.</param>
 /// <param name="billingCompanyId">The billing company identifier.</param>
 /// <param name="billingAccountUsername">The billing account username.</param>
 /// <param name="billingAccountPassword">The billing account password.</param>
 /// <exception cref="System.ArgumentNullException"></exception>
 public BillingAccount(BillingAccountId billingAccountId, BillingCompanyId billingCompanyId,
                       string billingAccountUsername, string billingAccountPassword, APSUser apsUser)
 {
     if (billingAccountId != null && billingCompanyId != null &&
         !string.IsNullOrEmpty(billingAccountUsername) && !string.IsNullOrEmpty(billingAccountPassword))
     {
         _billingAccountId       = billingAccountId;
         _billingCompanyId       = billingCompanyId;
         _billingAccountUsername = billingAccountUsername;
         _billingAccountPassword = billingAccountPassword;
         _apsUser = apsUser;
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BillingAccount"/> class.
 /// </summary>
 /// <param name="billingAccountId">The billing account identifier.</param>
 /// <param name="billingCompanyId">The billing company identifier.</param>
 /// <param name="billingAccountUsername">The billing account username.</param>
 /// <param name="billingAccountPassword">The billing account password.</param>
 /// <exception cref="System.ArgumentNullException"></exception>
 public BillingAccount(BillingAccountId billingAccountId, BillingCompanyId billingCompanyId, 
     string billingAccountUsername, string billingAccountPassword, APSUser apsUser)
 {
     if (billingAccountId != null && billingCompanyId !=null &&
         !string.IsNullOrEmpty(billingAccountUsername) && !string.IsNullOrEmpty(billingAccountPassword))
     {
         _billingAccountId = billingAccountId;
         _billingCompanyId = billingCompanyId;
         _billingAccountUsername = billingAccountUsername;
         _billingAccountPassword = billingAccountPassword;
         _apsUser = apsUser;
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
        public APSUser GetAPSUserById(APSUserId apsUserId)
        {
            APSUser localAPSUser;
            DataTable dt = dataConnection.SelectQuery("Select query to retrieve APS User by APSUserId");

            if (dt.Rows.Count == 1)
            {
                DataRow dr = dt.Rows[0];
                localAPSUser = new APSUser((APSUserId)dr["apsUserId"], (string)dr["apsUsername"], (string)dr["apsUserPassword"]);
            }
            else
            {
                throw new Exception("There can be only one APS User per APSUserId");
            }

            return localAPSUser;
        }
        public void Create_BillingAccount_ExpectValid()
        {
            //Arrange
            string localBillingAccountIdString = "APSBA01";
            string localBillingCompanyIdString = "COJ01";
            string localBillingAccountUsername = "******";
            string localBillingAccountPassword = "******";
            BillingAccountId localBillingAccountId = new BillingAccountId(localBillingAccountIdString);
            BillingCompanyId localBillingCompanyId = new BillingCompanyId(localBillingCompanyIdString);
            APSUser localAPSUser = new APSUser(new APSUserId("1"), "testuser", "testPasssword");

            //Act
            BillingAccount localBillingAccount = new BillingAccount(localBillingAccountId,
                localBillingCompanyId, localBillingAccountUsername, localBillingAccountPassword, localAPSUser);

            //Assert
            Assert.AreEqual(localBillingAccount.BillingAccountId, localBillingAccountId);
            Assert.AreEqual(localBillingAccount.BillingCompanyId, localBillingCompanyId);
            Assert.AreEqual(localBillingAccount.BillingAccountUsername, localBillingAccountUsername);
            Assert.AreEqual(localBillingAccount.BillingAccountPassword, localBillingAccountPassword);
        }
        public void Create_BillingAccount_ExpectValid()
        {
            //Arrange
            string           localBillingAccountIdString = "APSBA01";
            string           localBillingCompanyIdString = "COJ01";
            string           localBillingAccountUsername = "******";
            string           localBillingAccountPassword = "******";
            BillingAccountId localBillingAccountId       = new BillingAccountId(localBillingAccountIdString);
            BillingCompanyId localBillingCompanyId       = new BillingCompanyId(localBillingCompanyIdString);
            APSUser          localAPSUser = new APSUser(new APSUserId("1"), "testuser", "testPasssword");

            //Act
            BillingAccount localBillingAccount = new BillingAccount(localBillingAccountId,
                                                                    localBillingCompanyId, localBillingAccountUsername, localBillingAccountPassword, localAPSUser);

            //Assert
            Assert.AreEqual(localBillingAccount.BillingAccountId, localBillingAccountId);
            Assert.AreEqual(localBillingAccount.BillingCompanyId, localBillingCompanyId);
            Assert.AreEqual(localBillingAccount.BillingAccountUsername, localBillingAccountUsername);
            Assert.AreEqual(localBillingAccount.BillingAccountPassword, localBillingAccountPassword);
        }
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    APSUser apsUser = AccountsRepo.GetUserAccountByUsernameAndPassword(model.Username, model.Password);
                    if (apsUser != null)
                    {
                        FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);
                        FakeData.UserID = apsUser.APSUserId.IdString;

                        if (this.Url.IsLocalUrl(returnUrl))
                        {
                            return(Redirect(returnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Incorrect Username or Password");
                        return(View(model));
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message.ToString());
                    return(View(model));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 21
0
        public void Add_BillingAccount_ExpectAccountAdded()
        {
            //Arrange
            string localAPSUserIdString = "APS01";
            string localUsername = "******";
            string localPassword = "******";
            APSUserId localAPSUserId = new APSUserId(localAPSUserIdString);
            APSUser localAPSUser = new APSUser(localAPSUserId, localUsername, localPassword);

            string localBillingAccountIdString = "APSBA01";
            string localBillingCompanyIdString = "COJ01";
            string localBillingAccountUsername = "******";
            string localBillingAccountPassword = "******";
            BillingAccountId localBillingAccountId = new BillingAccountId(localBillingAccountIdString);
            BillingCompanyId localBillingCompanyId = new BillingCompanyId(localBillingCompanyIdString);
            BillingAccount localBillingAccount = new BillingAccount(localBillingAccountId,
               localBillingCompanyId, localBillingAccountUsername, localBillingAccountPassword, localAPSUser);

            //Act
            localAPSUser.AddBillingAccount(localBillingAccount);

            //Assert
            Assert.AreEqual(localAPSUser.BillingAccounts.First(ba => ba.BillingAccountId == localBillingAccountId),localBillingAccount);
        }
Exemplo n.º 22
0
        public void Add_BillingAccount_ExpectAccountAdded()
        {
            //Arrange
            string    localAPSUserIdString = "APS01";
            string    localUsername        = "******";
            string    localPassword        = "******";
            APSUserId localAPSUserId       = new APSUserId(localAPSUserIdString);
            APSUser   localAPSUser         = new APSUser(localAPSUserId, localUsername, localPassword);

            string           localBillingAccountIdString = "APSBA01";
            string           localBillingCompanyIdString = "COJ01";
            string           localBillingAccountUsername = "******";
            string           localBillingAccountPassword = "******";
            BillingAccountId localBillingAccountId       = new BillingAccountId(localBillingAccountIdString);
            BillingCompanyId localBillingCompanyId       = new BillingCompanyId(localBillingCompanyIdString);
            BillingAccount   localBillingAccount         = new BillingAccount(localBillingAccountId,
                                                                              localBillingCompanyId, localBillingAccountUsername, localBillingAccountPassword, localAPSUser);

            //Act
            localAPSUser.AddBillingAccount(localBillingAccount);

            //Assert
            Assert.AreEqual(localAPSUser.BillingAccounts.First(ba => ba.BillingAccountId == localBillingAccountId), localBillingAccount);
        }
        public ActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                APSUser user = new APSUser(new APSUserId(Guid.NewGuid().ToString()), model.Username, model.Password);
                AccountsRepo.InsertAPSUser(user);

                FormsAuthentication.SetAuthCookie(user.APSUsername, false);
                FakeData.UserID = user.APSUserId.IdString;
                return RedirectToAction("Index", "Home");
            }

            return View();
        }