private void populateVariety() { ProgramVarietyTable programVarietyTable = new ProgramVarietyTable(); programVarietyModelAdvanced = new ProgramVarietyModel(); programVarietyModelAdvanced.name = "Advanced"; programVarietyModelAdvanced.depositAmount = 30.0; programVarietyModelAdvanced.fullPaymentPercentageDiscount = 0; programVarietyModelAdvanced.sessionCost = 30.0; programVarietyModelAdvanced.noOfClasses = 8; programVarietyModelAdvanced.dogSpacesMaximum = 8; programVarietyIdAdvanced = programVarietyTable.create(programVarietyModelAdvanced); programVarietyModelRegular = new ProgramVarietyModel(); programVarietyModelRegular.name = "Regular"; programVarietyModelRegular.depositAmount = 20.0; programVarietyModelRegular.fullPaymentPercentageDiscount = 10.0; programVarietyModelRegular.sessionCost = 25.0; programVarietyModelRegular.noOfClasses = 6; programVarietyModelRegular.dogSpacesMaximum = 10; programVarietyIdRegular = programVarietyTable.create(programVarietyModelRegular); }
public void Setup() { new DataStoreTableHelper().clearAllTables(); ClientModel clientModel = new ClientModel(); clientModel.forename = "Bob"; clientModel.phone = "1234567890"; clientModel.email = "*****@*****.**"; ClientTable clientTable = new ClientTable(); clientId = clientTable.create(clientModel); DogModel dogModel = new DogModel(); dogModel.clientID = clientId; dogModel.name = "Dog"; dogModel.age = 6; dogModel.breed = "Terrier"; dogModel.experienceOrQualification = false; DogTable dogTable = new DogTable(); dogId = dogTable.create(dogModel); ProgramVarietyModel programeVarietyModel = new ProgramVarietyModel(); programeVarietyModel.depositAmount = 20.0; programeVarietyModel.sessionCost = 20.0; programeVarietyModel.fullPaymentPercentageDiscount = 20; programeVarietyModel.name = "Regular"; programeVarietyModel.dogSpacesMaximum = 50; programeVarietyModel.noOfClasses = 50; ProgramVarietyTable programVarietyTable = new ProgramVarietyTable(); programeVarietyId = programVarietyTable.create(programeVarietyModel); ProgramModel programModel = new ProgramModel(); programModel.programVarietyId = programeVarietyId; ProgramTable programTable = new ProgramTable(); programId = programTable.create(programModel); }
public void Setup() { new DataStoreTableHelper().clearAllTables(); ProgramVarietyModel programeVarietyModel = new ProgramVarietyModel(); programeVarietyModel.depositAmount = 20.0; programeVarietyModel.sessionCost = 20.0; programeVarietyModel.fullPaymentPercentageDiscount = 20; programeVarietyModel.name = "Advanced"; programeVarietyModel.dogSpacesMaximum = 10; programeVarietyModel.noOfClasses = 10; ProgramVarietyTable programVarietyTable = new ProgramVarietyTable(); programVarietyId = programVarietyTable.create(programeVarietyModel); }
public void Count_Created1Record_1() { //Assemble ProgramVarietyModel programVarietyModel = new ProgramVarietyModel(); programVarietyModel.depositAmount = 49.0; programVarietyModel.sessionCost = 50.0; programVarietyModel.fullPaymentPercentageDiscount = 51.0; programVarietyModel.name = "Advanced"; programVarietyModel.noOfClasses = 10; programVarietyModel.dogSpacesMaximum = 9; int expected = 1; ProgramVarietyTable programCostTable = new ProgramVarietyTable(); //Act int programCostID = programCostTable.create(programVarietyModel); int actual = programCostTable.count(); //Assert Assert.AreEqual(expected, actual); }
public void Create_ValidData_ProgramVarietyIDReturned() { //Assemble ProgramVarietyModel programVarietyModel = new ProgramVarietyModel(); programVarietyModel.depositAmount = 49.0; programVarietyModel.sessionCost = 50.0; programVarietyModel.fullPaymentPercentageDiscount = 51.0; programVarietyModel.name = "Advanced"; programVarietyModel.noOfClasses = 10; programVarietyModel.dogSpacesMaximum = 9; //If created will be greater than 0, but we don't know exactly what it will be because deleting all records doesnt set the ID counter back to 0 int notCreated = 0; ProgramVarietyTable programCostTable = new ProgramVarietyTable(); //Act int actual = programCostTable.create(programVarietyModel); //Assert Assert.AreNotEqual(notCreated, actual); }
public void Read_CreatedAndRead1Record_CorrectValues() { //Assemble ProgramVarietyModel programVarietyModel = new ProgramVarietyModel(); programVarietyModel.depositAmount = 49.0; programVarietyModel.sessionCost = 50.0; programVarietyModel.fullPaymentPercentageDiscount = 51.0; programVarietyModel.name = "Advanced"; programVarietyModel.noOfClasses = 10; programVarietyModel.dogSpacesMaximum = 9; ProgramVarietyTable programCostTable = new ProgramVarietyTable(); //Act int programCostID = programCostTable.create(programVarietyModel); ProgramVarietyModel actual = programCostTable.read(programCostID); //Assert Assert.AreEqual(programVarietyModel.depositAmount, actual.depositAmount); Assert.AreEqual(programVarietyModel.sessionCost, actual.sessionCost); Assert.AreEqual(programVarietyModel.dogSpacesMaximum, actual.dogSpacesMaximum); Assert.AreEqual(programVarietyModel.noOfClasses, actual.noOfClasses); }
public void ReadAll_Create3Records_3DifferentRecords() { //Assemble ProgramVarietyModel programVarietyModel1 = new ProgramVarietyModel(); programVarietyModel1.depositAmount = 49.1; programVarietyModel1.sessionCost = 50.1; programVarietyModel1.fullPaymentPercentageDiscount = 51.1; programVarietyModel1.name = "Advanced"; programVarietyModel1.noOfClasses = 10; programVarietyModel1.dogSpacesMaximum = 9; ProgramVarietyModel programVarietyModel2 = new ProgramVarietyModel(); programVarietyModel2.depositAmount = 49.2; programVarietyModel2.sessionCost = 50.2; programVarietyModel2.fullPaymentPercentageDiscount = 51.2; programVarietyModel2.name = "Regular"; programVarietyModel2.noOfClasses = 8; programVarietyModel2.dogSpacesMaximum = 7; ProgramVarietyModel programVarietyModel3 = new ProgramVarietyModel(); programVarietyModel3.depositAmount = 49.3; programVarietyModel3.sessionCost = 50.3; programVarietyModel3.fullPaymentPercentageDiscount = 51.3; programVarietyModel3.name = "Advanced"; programVarietyModel3.noOfClasses = 6; programVarietyModel3.dogSpacesMaximum = 5; ProgramVarietyTable programCostTable = new ProgramVarietyTable(); //Act int programCostID1 = programCostTable.create(programVarietyModel1); int programCostID2 = programCostTable.create(programVarietyModel2); int programCostID3 = programCostTable.create(programVarietyModel3); List <ProgramVarietyModel> actual = programCostTable.readAll(); //Assert Assert.AreEqual(programCostID1, programCostID1); Assert.AreEqual(programVarietyModel1.depositAmount, actual[0].depositAmount); Assert.AreEqual(programVarietyModel1.sessionCost, actual[0].sessionCost); Assert.AreEqual(programVarietyModel1.fullPaymentPercentageDiscount, actual[0].fullPaymentPercentageDiscount); Assert.AreEqual(programVarietyModel1.name, actual[0].name); Assert.AreEqual(programVarietyModel1.dogSpacesMaximum, actual[0].dogSpacesMaximum); Assert.AreEqual(programVarietyModel1.noOfClasses, actual[0].noOfClasses); Assert.AreEqual(programCostID2, programCostID2); Assert.AreEqual(programVarietyModel2.depositAmount, actual[1].depositAmount); Assert.AreEqual(programVarietyModel2.sessionCost, actual[1].sessionCost); Assert.AreEqual(programVarietyModel2.fullPaymentPercentageDiscount, actual[1].fullPaymentPercentageDiscount); Assert.AreEqual(programVarietyModel2.name, actual[1].name); Assert.AreEqual(programVarietyModel2.dogSpacesMaximum, actual[1].dogSpacesMaximum); Assert.AreEqual(programVarietyModel2.noOfClasses, actual[1].noOfClasses); Assert.AreEqual(programCostID3, programCostID3); Assert.AreEqual(programVarietyModel3.depositAmount, actual[2].depositAmount); Assert.AreEqual(programVarietyModel3.sessionCost, actual[2].sessionCost); Assert.AreEqual(programVarietyModel3.fullPaymentPercentageDiscount, actual[2].fullPaymentPercentageDiscount); Assert.AreEqual(programVarietyModel3.name, actual[2].name); Assert.AreEqual(programVarietyModel3.dogSpacesMaximum, actual[2].dogSpacesMaximum); Assert.AreEqual(programVarietyModel3.noOfClasses, actual[2].noOfClasses); }
public void Setup() { new DataStoreTableHelper().clearAllTables(); ClientModel clientModel = new ClientModel(); clientModel.displayName = "Barry Bonds"; clientModel.phone = "1234567890"; clientModel.email = "*****@*****.**"; ClientTable clientTable = new ClientTable(); clientId = clientTable.create(clientModel); DogModel dogModel = new DogModel(); dogModel.clientID = clientId; dogModel.name = "Dog"; dogModel.age = 6; dogModel.breed = "Terrier"; dogModel.experienceOrQualification = false; DogTable dogTable = new DogTable(); dogId = dogTable.create(dogModel); ProgramVarietyModel programeVarietyModel = new ProgramVarietyModel(); programeVarietyModel.depositAmount = 20.0; programeVarietyModel.sessionCost = 20.0; programeVarietyModel.fullPaymentPercentageDiscount = 20; programeVarietyModel.name = "Regular"; programeVarietyModel.dogSpacesMaximum = 50; programeVarietyModel.noOfClasses = 50; ProgramVarietyTable programVarietyTable = new ProgramVarietyTable(); programVarietyId = programVarietyTable.create(programeVarietyModel); ProgramModel programModel = new ProgramModel(); programModel.programVarietyId = programVarietyId; ProgramTable programTable = new ProgramTable(); programId = programTable.create(programModel); EnrollmentModel enrollmentModel = new EnrollmentModel(); enrollmentModel.name = "A"; enrollmentModel.clientId = clientId; enrollmentModel.dogId = dogId; enrollmentModel.programId = programId; enrollmentModel.paymentMethod = 1; enrollmentModel.joinDate = new DateTime(2021, 01, 03); enrollmentModel.inviteIssued = true; EnrollmentTable enrollmentTable = new EnrollmentTable(); enrollmentId = enrollmentTable.create(enrollmentModel); }
private static void populateDatabase() { //clear all the records in all the tables new DataStoreTableHelper().clearAllTables(); //check the tables are empty consoleTableCounts(); //Adding some records to it will be easier to create and update the screens //add Client records ClientTable clientTable = new ClientTable(); ClientModel clientModelBob = new ClientModel(); clientModelBob.forename = "Bob"; clientModelBob.surname = "White"; clientModelBob.phone = "1234567890"; clientModelBob.email = "*****@*****.**"; clientModelBob.displayName = clientModelBob.forename + " " + clientModelBob.surname; int clientIdBob = clientTable.create(clientModelBob); ClientModel clientModelKate = new ClientModel(); clientModelKate.forename = "Kate"; clientModelKate.surname = "Black"; clientModelKate.phone = "1234567890"; clientModelKate.email = "*****@*****.**"; clientModelKate.displayName = clientModelKate.forename + " " + clientModelKate.surname; int clientIdKate = clientTable.create(clientModelKate); //add Dog records DogTable dogTable = new DogTable(); DogModel dogModelBoxer = new DogModel(); dogModelBoxer.name = "Boxer"; dogModelBoxer.clientID = clientIdBob; dogModelBoxer.age = 7; dogModelBoxer.breed = "Bulldog"; int dogIdBoxer = dogTable.create(dogModelBoxer); DogModel dogModelTed = new DogModel(); dogModelTed.name = "Ted"; dogModelTed.clientID = clientIdKate; dogModelTed.age = 7; dogModelTed.breed = "Shi Tzu"; int dogIdTed = dogTable.create(dogModelTed); //add Staff records StaffTable staffTable = new StaffTable(); StaffModel staffModelBob = new StaffModel(); staffModelBob.name = "Bob"; int staffIdBob = staffTable.create(staffModelBob); StaffModel staffModelKate = new StaffModel(); staffModelKate.name = "Kate"; int staffIdKate = staffTable.create(staffModelKate); //add ProgramVariety records ProgramVarietyTable programVarietyTable = new ProgramVarietyTable(); ProgramVarietyModel programVarietyAdvanced = new ProgramVarietyModel(); programVarietyAdvanced.name = "Advanced"; programVarietyAdvanced.depositAmount = 30.0; programVarietyAdvanced.fullPaymentPercentageDiscount = 0.0; programVarietyAdvanced.sessionCost = 30.0; programVarietyAdvanced.noOfClasses = 8; programVarietyAdvanced.dogSpacesMaximum = 8; int programCostId1 = programVarietyTable.create(programVarietyAdvanced); ProgramVarietyModel programVarietyRegular = new ProgramVarietyModel(); programVarietyRegular.name = "Regular"; programVarietyRegular.depositAmount = 20.0; programVarietyRegular.fullPaymentPercentageDiscount = 10.0; programVarietyRegular.sessionCost = 25.0; programVarietyRegular.noOfClasses = 6; programVarietyRegular.dogSpacesMaximum = 10; int programCostId2 = programVarietyTable.create(programVarietyRegular); //add Program records ProgramTable programTable = new ProgramTable(); ProgramModel programModel1 = new ProgramModel(); programModel1.name = "Regular AM"; programModel1.programVarietyId = programCostId2; int programId1 = programTable.create(programModel1); ProgramModel programModel2 = new ProgramModel(); programModel2.name = "Regular PM"; programModel2.programVarietyId = programCostId2; int programId2 = programTable.create(programModel2); ProgramModel programModel3 = new ProgramModel(); programModel3.name = "Advanced"; programModel3.programVarietyId = programCostId1; int programId3 = programTable.create(programModel3); //add Enrollment records EnrollmentTable enrollmentTable = new EnrollmentTable(); EnrollmentModel enrollmentModel1 = new EnrollmentModel(); enrollmentModel1.name = dogModelBoxer.name + " (owned by " + clientModelBob.displayName + ") in " + programModel1.name; enrollmentModel1.clientId = clientIdBob; enrollmentModel1.dogId = dogIdBoxer; enrollmentModel1.programId = programId1; enrollmentModel1.paymentMethod = PaymentConstants.PAYMENT_IN_FULL; enrollmentModel1.joinDate = DateTime.Now; enrollmentModel1.inviteIssued = false; int enrollmentId1 = enrollmentTable.create(enrollmentModel1); EnrollmentModel enrollmentModel2 = new EnrollmentModel(); enrollmentModel2.name = dogModelTed.name + " (owned by " + clientModelKate.displayName + ") in " + programModel2.name; enrollmentModel2.clientId = clientIdKate; enrollmentModel2.dogId = dogIdTed; enrollmentModel2.programId = programId2; enrollmentModel2.paymentMethod = PaymentConstants.PAYMENT_PER_CLASS; enrollmentModel2.joinDate = DateTime.Now; enrollmentModel2.inviteIssued = true; int enrollmentId2 = enrollmentTable.create(enrollmentModel2); //check the tables have records consoleTableCounts(); }