public void ReadAll_Create3Records_CountIs3() { //Assemble ClientModel clientModel1 = new ClientModel(); clientModel1.name = "Bob"; clientModel1.phone = "07561 101169"; clientModel1.email = "*****@*****.**"; ClientModel clientModel2 = new ClientModel(); clientModel2.name = "Bob2"; clientModel2.phone = "07561 101169"; clientModel2.email = "*****@*****.**"; ClientModel clientModel3 = new ClientModel(); clientModel3.name = "Bob3"; clientModel3.phone = "07561 101169"; clientModel3.email = "*****@*****.**"; ClientTable clientTable = new ClientTable(); int expected = 3; //Act int clientID1 = clientTable.create(clientModel1); int clientID2 = clientTable.create(clientModel2); int clientID3 = clientTable.create(clientModel3); List <ClientModel> actual = clientTable.readAll(); //Assert Assert.AreEqual(expected, actual.Count); }
public void Update_CreatedUpdateAndRead1Record_UpdatedValues() { //Assemble ClientModel clientModel = new ClientModel(); clientModel.name = "Bob"; clientModel.phone = "07561 101169"; clientModel.email = "*****@*****.**"; ClientTable clientTable = new ClientTable(); int clientID = clientTable.create(clientModel); clientModel.id = clientID; clientModel.name = "Kate"; clientModel.phone = "07561 101170"; clientModel.email = "*****@*****.**"; //Act clientTable.update(clientModel); ClientModel actual = clientTable.read(clientID); //Assert Assert.AreEqual(clientModel.name, actual.name); Assert.AreEqual(clientModel.phone, actual.phone); Assert.AreEqual(clientModel.email, actual.email); }
public void CreateEmailConstraint_EmailLengthTooShort_Exception() { //Assemble ClientTable clientTable = new ClientTable(); ClientModel clientModel = new ClientModel(); clientModel.displayName = "Barry Bonds"; clientModel.phone = "1234567890"; clientModel.email = "*****@*****.**"; int expected = 1; int counter = 0; //Act try { int id = clientTable.create(clientModel); } catch (Exception ex) { counter++; } //Assert Assert.AreEqual(expected, counter); }
public void CreatePhoneConstraint_PhoneLengthOk_NoException() { //Assemble ClientTable clientTable = new ClientTable(); ClientModel clientModel = new ClientModel(); clientModel.displayName = "Barry Bonds"; clientModel.phone = "1234567890"; clientModel.email = "*****@*****.**"; int expected = 1; int counter = 0; //Act try { int id = clientTable.create(clientModel); counter++; } catch (Exception ex) { } //Assert Assert.AreEqual(expected, counter); }
public void CreateEmailConstraint_EmailLengthOk_NoException() { //Assemble ClientTable clientTable = new ClientTable(); ClientModel clientModel = new ClientModel(); clientModel.name = "Bob"; clientModel.phone = "1234567890"; clientModel.email = "*****@*****.**"; int expected = 1; int counter = 0; //Act try { int id = clientTable.create(clientModel); counter++; } catch (Exception ex) { } //Assert Assert.AreEqual(expected, counter); }
public void Setup() { new DataStoreTableHelper().clearAllTables(); ClientModel clientModel = new ClientModel(); clientModel.name = "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); ProgramTypeModel programTypeModel = new ProgramTypeModel(); programTypeModel.description = "Regular"; ProgramTypeTable programTypeTable = new ProgramTypeTable(); programTypeId = programTypeTable.create(programTypeModel); }
public void CreatePhoneConstraint_PhoneLengthTooShort_Exception() { //Assemble ClientTable clientTable = new ClientTable(); ClientModel clientModel = new ClientModel(); clientModel.name = "Bob"; clientModel.phone = "123456789"; clientModel.email = "*****@*****.**"; int expected = 1; int counter = 0; //Act try { int id = clientTable.create(clientModel); } catch (Exception ex) { counter++; } //Assert Assert.AreEqual(expected, counter); }
public void CreateNameConstraint_NameLengthOk_NoException() { //Assemble ClientTable clientTable = new ClientTable(); ClientModel clientModel = new ClientModel(); clientModel.name = "Bob"; clientModel.phone = "07561 101169"; clientModel.email = "*****@*****.**"; int expected = 1; int counter = 0; //Act try { int id = clientTable.create(clientModel); counter++; } catch (Exception ex) { } //Assert Assert.AreEqual(expected, counter); }
public void ReadAll_Create3Records_3DifferentRecords() { //Assemble ClientModel clientModel1 = new ClientModel(); clientModel1.name = "name1"; clientModel1.phone = "07561 101169"; clientModel1.email = "*****@*****.**"; ClientModel clientModel2 = new ClientModel(); clientModel2.name = "name2"; clientModel2.phone = "07561 101170"; clientModel2.email = "*****@*****.**"; ClientModel clientModel3 = new ClientModel(); clientModel3.name = "name3"; clientModel3.phone = "07561 101171"; clientModel3.email = "*****@*****.**"; ClientTable clientTable = new ClientTable(); //Act int clientID1 = clientTable.create(clientModel1); int clientID2 = clientTable.create(clientModel2); int clientID3 = clientTable.create(clientModel3); List <ClientModel> actual = clientTable.readAll(); //Assert Assert.AreEqual(clientID1, clientID1); Assert.AreEqual(clientModel1.name, actual[0].name); Assert.AreEqual(clientModel1.phone, actual[0].phone); Assert.AreEqual(clientModel1.email, actual[0].email); Assert.AreEqual(clientID2, clientID2); Assert.AreEqual(clientModel2.name, actual[1].name); Assert.AreEqual(clientModel2.phone, actual[1].phone); Assert.AreEqual(clientModel2.email, actual[1].email); Assert.AreEqual(clientID3, clientID3); Assert.AreEqual(clientModel3.name, actual[2].name); Assert.AreEqual(clientModel3.phone, actual[2].phone); Assert.AreEqual(clientModel3.email, actual[2].email); }
public void Setup() { new DataStoreTableHelper().clearAllTables(); ClientModel clientModel = new ClientModel(); clientModel.name = "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); ProgramTypeModel programTypeModel = new ProgramTypeModel(); programTypeModel.description = "Regular"; ProgramTypeTable programTypeTable = new ProgramTypeTable(); programTypeId = programTypeTable.create(programTypeModel); ProgramCostModel programeCostModel = new ProgramCostModel(); programeCostModel.depositAmount = 20.0; programeCostModel.sessionCost = 20.0; programeCostModel.fullPaymentPercentageDiscount = 20; ProgramCostTable programCostTable = new ProgramCostTable(); programeCostId = programCostTable.create(programeCostModel); ProgramModel programModel = new ProgramModel(); programModel.programTypeId = programTypeId; programModel.programCostId = programeCostId; programModel.dogSpacesMaximum = 50; programModel.noOfClasses = 50; ProgramTable programTable = new ProgramTable(); programId = programTable.create(programModel); }
public void Setup() { new DataStoreTableHelper().clearAllTables(); ClientModel clientModel = new ClientModel(); clientModel.name = "Bob"; clientModel.phone = "1234567890"; clientModel.email = "*****@*****.**"; ClientTable clientTable = new ClientTable(); clientId = clientTable.create(clientModel); }
public void Count_Created1Record_1() { //Assemble ClientModel clientModel = new ClientModel(); clientModel.name = "Bob"; clientModel.phone = "07561 101169"; clientModel.email = "*****@*****.**"; int expected = 1; ClientTable clientTable = new ClientTable(); //Act int clientID = clientTable.create(clientModel); int actual = clientTable.count(); //Assert Assert.AreEqual(expected, actual); }
public void Create_ValidData_ClientIDReturned() { //Assemble ClientModel clientModel = new ClientModel(); clientModel.name = "Bob"; clientModel.phone = "07561 101169"; clientModel.email = "*****@*****.**"; //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; ClientTable clientTable = new ClientTable(); //Act int actual = clientTable.create(clientModel); //Assert Assert.AreNotEqual(notCreated, actual); }
public void Read_CreatedAndRead1Record_CorrectValues() { //Assemble ClientModel clientModel = new ClientModel(); clientModel.name = "Bob"; clientModel.phone = "07561 101169"; clientModel.email = "*****@*****.**"; ClientTable clientTable = new ClientTable(); //Act int clientID = clientTable.create(clientModel); ClientModel actual = clientTable.read(clientID); //Assert Assert.AreEqual(clientModel.name, actual.name); Assert.AreEqual(clientModel.phone, actual.phone); Assert.AreEqual(clientModel.email, actual.email); }
public void Delete_CreatedDeleteAndCount1Record_0() { //Assemble ClientModel clientModel = new ClientModel(); clientModel.displayName = "Barry Bonds"; clientModel.phone = "07561 101169"; clientModel.email = "*****@*****.**"; int expected = 0; ClientTable clientTable = new ClientTable(); int clientID = clientTable.create(clientModel); //Act clientTable.delete(clientID); int actual = clientTable.count(); //Assert Assert.AreEqual(expected, actual); }
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(); }
private void populateClient() { ClientTable clientTable = new ClientTable(); clientModelBarry = new ClientModel(); clientModelBarry.forename = "James"; clientModelBarry.surname = "Jones"; clientModelBarry.phone = "1234567890"; clientModelBarry.email = "*****@*****.**"; clientModelBarry.displayName = clientModelBarry.forename + " " + clientModelBarry.surname; clientIdBarry = clientTable.create(clientModelBarry); clientModelJames = new ClientModel(); clientModelJames.forename = "Barry"; clientModelJames.surname = "Bonds"; clientModelJames.phone = "1234567891"; clientModelJames.email = "*****@*****.**"; clientModelJames.displayName = clientModelJames.forename + " " + clientModelJames.surname; clientIdJames = clientTable.create(clientModelJames); clientModelMark = new ClientModel(); clientModelMark.forename = "Mark"; clientModelMark.surname = "Murray"; clientModelMark.phone = "1234567892"; clientModelMark.email = "*****@*****.**"; clientModelMark.displayName = clientModelMark.forename + " " + clientModelMark.surname; clientIdMark = clientTable.create(clientModelMark); clientModelSam = new ClientModel(); clientModelSam.forename = "Sam"; clientModelSam.surname = "Spud"; clientModelSam.phone = "1234567893"; clientModelSam.email = "*****@*****.**"; clientModelSam.displayName = clientModelSam.forename + " " + clientModelSam.surname; clientIdSam = clientTable.create(clientModelSam); clientModelTed = new ClientModel(); clientModelTed.forename = "Ted"; clientModelTed.surname = "Teddington"; clientModelTed.phone = "1234567894"; clientModelTed.email = "*****@*****.**"; clientModelTed.displayName = clientModelTed.forename + " " + clientModelTed.surname; clientIdTed = clientTable.create(clientModelTed); clientModelJim = new ClientModel(); clientModelJim.forename = "Jim"; clientModelJim.surname = "Jones"; clientModelJim.phone = "1234567895"; clientModelJim.email = "*****@*****.**"; clientModelJim.displayName = clientModelJim.forename + " " + clientModelJim.surname; clientIdJim = clientTable.create(clientModelJim); clientModelRon = new ClientModel(); clientModelRon.forename = "Ron"; clientModelRon.surname = "Ronalds"; clientModelRon.phone = "1234567896"; clientModelRon.email = "*****@*****.**"; clientModelRon.displayName = clientModelRon.forename + " " + clientModelRon.surname; clientIdRon = clientTable.create(clientModelRon); clientModelSid = new ClientModel(); clientModelSid.forename = "Sid"; clientModelSid.surname = "Siddle"; clientModelSid.phone = "1234567897"; clientModelSid.email = "*****@*****.**"; clientModelSid.displayName = clientModelSid.forename + " " + clientModelSid.surname; clientIdSid = clientTable.create(clientModelSid); }
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); }