static void testSGReadModifyRewrite(long SGID) { Console.WriteLine("\n\n-------------------- Test: Recreate, Modify, Rewrite Existing SavingsGoal --------------------"); // Reinstantiate a SavingsGoal from DB records SavingsGoalService sgService = new SavingsGoalService(); SavingsGoal existingGoal = sgService.getUsingID(SGID); // Print summary of goal that was just reinstantiated Console.WriteLine("Savings Goal Summary:\n---------------------"); Console.WriteLine(existingGoal + "\n"); // Modify the payment period, system recalculates end date, redisplay summary existingGoal.updatePeriod(contrPeriod.Weekly); Console.WriteLine("Savings Goal Summary:\n---------------------"); Console.WriteLine(existingGoal + "\n"); // Modify the payment amound to half, system recalculates number of payment periods needed and end date, redisplay summary existingGoal.updateContrAmt(existingGoal.contrAmt * 2); Console.WriteLine("Savings Goal Summary:\n---------------------"); Console.WriteLine(existingGoal + "\n"); // Rewrite the modified goal to DB sgService.update(existingGoal); }
public UserAccountService() { this.UserAccountDataAccess = new UserAccountDataAccess(); this.PasswordService = new PasswordService(); this.TransactionService = new TransactionService(); this.SGService = new SavingsGoalService(); this.RService = new ReceiptService(); this.SubService = new SubscriptionService(); }
static void testSGShowJSON(SavingsGoal sg) { Console.WriteLine("\n\n-------------------- Test: Display JSON of SavingsGoal Object --------------------"); // Print the JSON representation of the goal we created SavingsGoalService sgService = new SavingsGoalService(); Console.WriteLine(sgService.getJSON(sg)); }
static void testGetAllSGFromAcc(long accID) { Console.WriteLine("\n\n-------------------- Test: Retrieve All Savings Goals From Account --------------------"); SavingsGoalService sgService = new SavingsGoalService(); List <SavingsGoal> goals = sgService.getSavingsGoalsFromAccount(accID); foreach (SavingsGoal goal in goals) { Console.WriteLine(goal); } }
static void testSGShowSerialize(SavingsGoal sg) { Console.WriteLine("\n\n-------------------- Test: Display String Serialization of SavingsGoal Object --------------------"); // Serialize the runtime object to String[] SavingsGoalService sgService = new SavingsGoalService(); string[] serialized = sgService.serialize(sg); Console.WriteLine("\nSavingsGoal Serialized:\n-----------------------\n"); // Print the serialized SavingsGoal foreach (string attr in serialized) { Console.WriteLine(" " + attr); } }
static SavingsGoal testSGCreateByContrAmt() { Console.WriteLine("\n\n-------------------- Test: Creating A New Savings Goal By Contribution Amount, Write --------------------"); // Query DB for the next avail ID SavingsGoalService sgService = new SavingsGoalService(); long SGID = sgService.getNextAvailID(); Console.WriteLine("Next available SGID that can be assigned: " + SGID + "\n"); // Create a new Savings Goal for the amount of $300 dynamically calculate end date DateTime endDate = new DateTime(2021, 12, 20, 0, 0, 0).Date; SavingsGoal sampleGoal = new SavingsGoal(SGID, 2, "Tuition", (decimal)3425.00, contrPeriod.Weekly, (decimal)325.00); // Print summary of goal that was just created Console.WriteLine("Savings Goal Summary:\n---------------------"); Console.WriteLine(sampleGoal); // Write SavingsGoal object to DB sgService.write(sampleGoal); return(sampleGoal); }
// --------------------------------------------------- Begin Savings Goal Testing --------------------------------------------------- static SavingsGoal testSGCreateByDate() { Console.WriteLine("\n-------------------- Test: Creating A New Savings Goal By End Date, Write --------------------"); // Query DB for the next avail ID SavingsGoalService sgService = new SavingsGoalService(); long SGID = sgService.getNextAvailID(); Console.WriteLine("Next available SGID that can be assigned: " + SGID + "\n"); // Create a new Savings Goal for the amount of $150 ending on December 20th, dynamically calculate payments DateTime endDate = new DateTime(2021, 12, 20, 0, 0, 0).Date; SavingsGoal sampleGoal = new SavingsGoal(SGID, 2, "Christmas Gift", (decimal)150.00, contrPeriod.Monthly, endDate); // Print summary of goal that was just created Console.WriteLine("Savings Goal Summary:\n---------------------"); Console.WriteLine(sampleGoal); // Write SavingsGoal object to DB sgService.write(sampleGoal); return(sampleGoal); }