Example #1
0
        public void ReadAll_Create3Records_3DifferentRecords()
        {
            //Assemble
            DogModel dogModel1 = new DogModel();

            dogModel1.name     = "Ted";
            dogModel1.clientID = clientId;
            dogModel1.age      = 8;
            dogModel1.breed    = "Shi Tzu";
            dogModel1.experienceOrQualification = false;

            DogModel dogModel2 = new DogModel();

            dogModel2.name     = "Ted 2";
            dogModel2.clientID = clientId;
            dogModel2.age      = 82;
            dogModel2.breed    = "Shi Tzu 2";
            dogModel2.experienceOrQualification = true;

            DogModel dogModel3 = new DogModel();

            dogModel3.name     = "Ted 3";
            dogModel3.clientID = clientId;
            dogModel3.age      = 83;
            dogModel3.breed    = "Shi Tzu 3";
            dogModel3.experienceOrQualification = false;

            DogTable dogTable = new DogTable();

            //Act
            int             dogID1 = dogTable.create(dogModel1);
            int             dogID2 = dogTable.create(dogModel2);
            int             dogID3 = dogTable.create(dogModel3);
            List <DogModel> actual = dogTable.readAll();

            //Assert
            Assert.AreEqual(dogID1, dogID1);
            Assert.AreEqual(dogModel1.name, actual[0].name);
            Assert.AreEqual(dogModel1.clientID, actual[0].clientID);
            Assert.AreEqual(dogModel1.age, actual[0].age);
            Assert.AreEqual(dogModel1.breed, actual[0].breed);
            Assert.AreEqual(dogModel1.experienceOrQualification, actual[0].experienceOrQualification);

            Assert.AreEqual(dogID2, dogID2);
            Assert.AreEqual(dogModel2.name, actual[1].name);
            Assert.AreEqual(dogModel2.clientID, actual[1].clientID);
            Assert.AreEqual(dogModel2.age, actual[1].age);
            Assert.AreEqual(dogModel2.breed, actual[1].breed);
            Assert.AreEqual(dogModel2.experienceOrQualification, actual[1].experienceOrQualification);

            Assert.AreEqual(dogID3, dogID3);
            Assert.AreEqual(dogModel3.name, actual[2].name);
            Assert.AreEqual(dogModel3.clientID, actual[2].clientID);
            Assert.AreEqual(dogModel3.age, actual[2].age);
            Assert.AreEqual(dogModel3.breed, actual[2].breed);
            Assert.AreEqual(dogModel3.experienceOrQualification, actual[2].experienceOrQualification);
        }
Example #2
0
        public void Update_CreatedUpdateAndRead1Record_UpdatedValues()
        {
            //Assemble
            DogModel dogModel = new DogModel();

            dogModel.name     = "Ted";
            dogModel.clientID = clientId;
            dogModel.age      = 8;
            dogModel.breed    = "Shi Tzu";
            dogModel.experienceOrQualification = false;
            DogTable dogTable = new DogTable();
            int      dogID    = dogTable.create(dogModel);

            dogModel.id       = dogID;
            dogModel.clientID = clientId;
            dogModel.name     = "Coco";
            dogModel.age      = 17;
            dogModel.breed    = "Yorkshire Terrier";
            dogModel.experienceOrQualification = true;

            //Act
            dogTable.update(dogModel);
            DogModel actual = dogTable.read(dogID);

            //Assert
            Assert.AreEqual(dogModel.name, actual.name);
            Assert.AreEqual(dogModel.clientID, actual.clientID);
            Assert.AreEqual(dogModel.age, actual.age);
            Assert.AreEqual(dogModel.breed, actual.breed);
            Assert.AreEqual(dogModel.experienceOrQualification, actual.experienceOrQualification);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        public void ReadAll_Create3Records_CountIs3()
        {
            //Assemble
            DogModel dogModel1 = new DogModel();

            dogModel1.name     = "Ted";
            dogModel1.clientID = clientId;
            dogModel1.age      = 8;
            dogModel1.breed    = "Shi Tzu";
            dogModel1.experienceOrQualification = false;

            DogModel dogModel2 = new DogModel();

            dogModel2.name     = "Ted 2";
            dogModel2.clientID = clientId;
            dogModel2.age      = 82;
            dogModel2.breed    = "Shi Tzu 2";
            dogModel2.experienceOrQualification = true;

            DogModel dogModel3 = new DogModel();

            dogModel3.name     = "Ted 3";
            dogModel3.clientID = clientId;
            dogModel3.age      = 83;
            dogModel3.breed    = "Shi Tzu 3";
            dogModel3.experienceOrQualification = false;

            DogTable dogTable = new DogTable();
            int      expected = 3;

            //Act
            int             dogID1 = dogTable.create(dogModel1);
            int             dogID2 = dogTable.create(dogModel2);
            int             dogID3 = dogTable.create(dogModel3);
            List <DogModel> actual = dogTable.readAll();

            //Assert
            Assert.AreEqual(expected, actual.Count);
        }
Example #6
0
        public void Count_Created1Record_1()
        {
            //Assemble
            DogModel dogModel = new DogModel();

            dogModel.name     = "Ted";
            dogModel.clientID = clientId;
            dogModel.age      = 8;
            dogModel.breed    = "Shi Tzu";
            dogModel.experienceOrQualification = false;
            int      expected = 1;
            DogTable dogTable = new DogTable();

            //Act
            int dogID  = dogTable.create(dogModel);
            int actual = dogTable.count();

            //Assert
            Assert.AreEqual(expected, actual);
        }
Example #7
0
        public void Create_ValidData_DogIDReturned()
        {
            //Assemble
            DogModel dogModel = new DogModel();

            dogModel.name     = "Ted";
            dogModel.clientID = clientId;
            dogModel.age      = 8;
            dogModel.breed    = "Shi Tzu";
            dogModel.experienceOrQualification = false;
            //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;
            DogTable dogTable   = new DogTable();

            //Act
            int actual = dogTable.create(dogModel);

            //Assert
            Assert.AreNotEqual(notCreated, actual);
        }
Example #8
0
        public void Read_CreatedAndRead1Record_CorrectValues()
        {
            //Assemble
            DogModel dogModel = new DogModel();

            dogModel.name     = "Ted";
            dogModel.clientID = clientId;
            dogModel.age      = 8;
            dogModel.breed    = "Shi Tzu";
            dogModel.experienceOrQualification = false;
            DogTable dogTable = new DogTable();

            //Act
            int      dogID  = dogTable.create(dogModel);
            DogModel actual = dogTable.read(dogID);

            //Assert
            Assert.AreEqual(dogModel.name, actual.name);
            Assert.AreEqual(dogModel.clientID, actual.clientID);
            Assert.AreEqual(dogModel.age, actual.age);
            Assert.AreEqual(dogModel.breed, actual.breed);
            Assert.AreEqual(dogModel.experienceOrQualification, actual.experienceOrQualification);
        }
Example #9
0
        private void populateDog()
        {
            DogTable dogTable = new DogTable();

            dogModelThor          = new DogModel();
            dogModelThor.name     = "Thor";
            dogModelThor.clientID = clientIdJames;
            dogModelThor.age      = 1;
            dogModelThor.breed    = "Bulldog";
            dogModelThor.experienceOrQualification = false;
            dogIdThor = dogTable.create(dogModelThor);

            dogModelOdin          = new DogModel();
            dogModelOdin.name     = "Odin";
            dogModelOdin.clientID = clientIdJames;
            dogModelOdin.age      = 2;
            dogModelOdin.breed    = "Shi Tzu";
            dogModelOdin.experienceOrQualification = true;
            dogIdOdin = dogTable.create(dogModelOdin);

            dogModelLoki          = new DogModel();
            dogModelLoki.name     = "Loki";
            dogModelLoki.clientID = clientIdJames;
            dogModelLoki.age      = 3;
            dogModelLoki.breed    = "Beadle";
            dogModelLoki.experienceOrQualification = true;
            dogIdLoki = dogTable.create(dogModelLoki);

            dogModelHela          = new DogModel();
            dogModelHela.name     = "Hela";
            dogModelHela.clientID = clientIdMark;
            dogModelHela.age      = 4;
            dogModelHela.breed    = "Poodle";
            dogModelHela.experienceOrQualification = false;
            dogIdHela = dogTable.create(dogModelHela);

            dogModelHeimdall          = new DogModel();
            dogModelHeimdall.name     = "Heimdall";
            dogModelHeimdall.clientID = clientIdMark;
            dogModelHeimdall.age      = 5;
            dogModelHeimdall.breed    = "Bulldog";
            dogModelHeimdall.experienceOrQualification = true;
            dogIdHeimdall = dogTable.create(dogModelHeimdall);

            dogModelBaldur          = new DogModel();
            dogModelBaldur.name     = "Baldur";
            dogModelBaldur.clientID = clientIdMark;
            dogModelBaldur.age      = 6;
            dogModelBaldur.breed    = "Shi Tzu";
            dogModelBaldur.experienceOrQualification = false;
            dogIdBaldur = dogTable.create(dogModelBaldur);

            dogModelBragi          = new DogModel();
            dogModelBragi.name     = "Bragi";
            dogModelBragi.clientID = clientIdTed;
            dogModelBragi.age      = 7;
            dogModelBragi.breed    = "Poodle";
            dogModelBragi.experienceOrQualification = true;
            dogIdBragi = dogTable.create(dogModelBragi);

            dogModelIdun          = new DogModel();
            dogModelIdun.name     = "Idun";
            dogModelIdun.clientID = clientIdTed;
            dogModelIdun.age      = 8;
            dogModelIdun.breed    = "Beagle";
            dogModelIdun.experienceOrQualification = false;
            dogIdIdun = dogTable.create(dogModelIdun);

            dogModelNjord          = new DogModel();
            dogModelNjord.name     = "Njord";
            dogModelNjord.clientID = clientIdSam;
            dogModelNjord.age      = 9;
            dogModelNjord.breed    = "Shi Tzu";
            dogModelNjord.experienceOrQualification = true;
            dogIdNjord = dogTable.create(dogModelNjord);

            dogModelFreya          = new DogModel();
            dogModelFreya.name     = "Freya";
            dogModelFreya.clientID = clientIdSam;
            dogModelFreya.age      = 10;
            dogModelFreya.breed    = "Bulldog";
            dogModelFreya.experienceOrQualification = false;
            dogIdFreya = dogTable.create(dogModelFreya);

            dogModelFreyer          = new DogModel();
            dogModelFreyer.name     = "Freyer";
            dogModelFreyer.clientID = clientIdBarry;
            dogModelFreyer.age      = 11;
            dogModelFreyer.breed    = "Pug";
            dogModelFreyer.experienceOrQualification = true;
            dogIdFreyer = dogTable.create(dogModelFreyer);

            dogModelForseti          = new DogModel();
            dogModelForseti.name     = "Forseti";
            dogModelForseti.clientID = clientIdBarry;
            dogModelForseti.age      = 12;
            dogModelForseti.breed    = "Beagle";
            dogModelForseti.experienceOrQualification = false;
            dogIdForseti = dogTable.create(dogModelForseti);

            dogModelYmir          = new DogModel();
            dogModelYmir.name     = "Ymir";
            dogModelYmir.clientID = clientIdJim;
            dogModelYmir.age      = 13;
            dogModelYmir.breed    = "Shi Tzu";
            dogModelYmir.experienceOrQualification = true;
            dogIdYmir = dogTable.create(dogModelYmir);

            dogModelMimir          = new DogModel();
            dogModelMimir.name     = "Mimir";
            dogModelMimir.clientID = clientIdJim;
            dogModelMimir.age      = 14;
            dogModelMimir.breed    = "Poodle";
            dogModelMimir.experienceOrQualification = false;
            dogIdMimir = dogTable.create(dogModelMimir);

            dogModelThurd          = new DogModel();
            dogModelThurd.name     = "Thurd";
            dogModelThurd.clientID = clientIdRon;
            dogModelThurd.age      = 15;
            dogModelThurd.breed    = "Great Dane";
            dogModelThurd.experienceOrQualification = true;
            dogIdThurd = dogTable.create(dogModelThurd);

            dogModelAngbroda          = new DogModel();
            dogModelAngbroda.name     = "Angbroda";
            dogModelAngbroda.clientID = clientIdSid;
            dogModelAngbroda.age      = 16;
            dogModelAngbroda.breed    = "Husky";
            dogModelAngbroda.experienceOrQualification = false;
            dogIdAngbroda = dogTable.create(dogModelAngbroda);
        }
Example #10
0
        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);
        }
Example #11
0
        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();
        }