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 ScrapeTask NewScrapeTask(BillingAccount billingAccount)
        {
            // This method builds a new task with its dependencies and returns it to the caller
            // All build logic is encapsulated in this method

            // Values are derived from the billingAccount object

            // The 3 rule types are created to exist with the task for future use, which could be
            // a retry after a scrape failed, and so on.

            // For the purposes of this prototype, some fake values will be entered
            StatementLifeCycleRule lifeCycleRule = new StatementLifeCycleRule(30, 5, 2);

            List<RetryAfterUnsuccessfulScrapeRule> retryRules = new List<RetryAfterUnsuccessfulScrapeRule>();
            retryRules.Add(new RetryAfterUnsuccessfulScrapeRule(ScheduleErrorType.APSError, 5));
            retryRules.Add(new RetryAfterUnsuccessfulScrapeRule(ScheduleErrorType.NoNewStatementError, 6));
            retryRules.Add(new RetryAfterUnsuccessfulScrapeRule(ScheduleErrorType.ScraperError, 7));

            List<WindowPeriodRule> windowPeriods = new List<WindowPeriodRule>();
            windowPeriods.Add(new WindowPeriodRule(new TimeOfDay(1, 0, 0), new TimeOfDay(6, 0, 0)));
            windowPeriods.Add(new WindowPeriodRule(new TimeOfDay(19, 0, 0), new TimeOfDay(23, 0, 0)));

            ScrapeTask newTask = new ScrapeTask(Guid.NewGuid().ToString(), billingAccount.BillingAccountId.ToString(), windowPeriods, retryRules, lifeCycleRule);
            return newTask;
        }
 public bool InsertBillingAccount(BillingAccount BA)
 {
     try
     {
         FakeData.BillingAccounts.Add(BA);
         return true;
     }
     catch
     {
         return false;
     }
 }
        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 bool UpdateBillingAccount(BillingAccount BA)
        {
            try
            {
                int index = FakeData.BillingAccounts.FindIndex(x => x.BillingAccountId.IdString == BA.BillingAccountId.IdString);
                FakeData.BillingAccounts[index] = BA;

                return true;
            }
            catch
            {
                return false;
            }
        }
        public void DetectNewBillingAccountTaskTest()
        {
            // Arrange
            APSUser.APSUser user = new APSUser.APSUser(new APSUserId(Guid.NewGuid().ToString()), "usenrame1", "password1");
            BillingCompany billingCompany = new BillingCompany(new BillingCompanyId(Guid.NewGuid().ToString()), "PVC Test Company");
            BillingAccount billingAccount = new BillingAccount(new BillingAccountId(Guid.NewGuid().ToString()), billingCompany.billingCompanyId, "username1", "password1", user);

            Schedule MySchedule = new Schedule(taskRepo, billingAccountRepo, scrapeTaskFactory);

            // Act
            int TasksCreatedCount = MySchedule.CreateNewTasks();

            // Assert
            Assert.IsTrue(TasksCreatedCount == 1);
        }
        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 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);
        }
 /// <summary>
 /// Entities compare by identity, not by attributes.
 /// </summary>
 /// <param name="other">The other entity.</param>
 /// <returns>
 /// true if the identities are the same, regardles of other attributes.
 /// </returns>
 public virtual bool SameIdentityAs(BillingAccount other)
 {
     return BillingAccountId.SameValueAs(other.BillingAccountId);
 }
 public void ActOnError(BillingAccount billingAccount = null)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Entities compare by identity, not by attributes.
 /// </summary>
 /// <param name="other">The other entity.</param>
 /// <returns>
 /// true if the identities are the same, regardles of other attributes.
 /// </returns>
 public virtual bool SameIdentityAs(BillingAccount other)
 {
     return(BillingAccountId.SameValueAs(other.BillingAccountId));
 }