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 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();
        }
        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.º 5
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);
        }
        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;
        }
 /// <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 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);
        }
Exemplo n.º 9
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();
        }