Beispiel #1
0
        public void ReadAll_Create3Records_3DifferentRecords()
        {
            //Assemble
            StaffModel staffModel1 = new StaffModel();

            staffModel1.name = "name1";


            StaffModel staffModel2 = new StaffModel();

            staffModel2.name = "name2";

            StaffModel staffModel3 = new StaffModel();

            staffModel3.name = "name3";

            StaffTable staffTable = new StaffTable();

            //Act
            int staffID1             = staffTable.create(staffModel1);
            int staffID2             = staffTable.create(staffModel2);
            int staffID3             = staffTable.create(staffModel3);
            List <StaffModel> actual = staffTable.readAll();

            //Assert
            Assert.AreEqual(staffID1, staffID1);
            Assert.AreEqual(staffModel1.name, actual[0].name);

            Assert.AreEqual(staffID2, staffID2);
            Assert.AreEqual(staffModel2.name, actual[1].name);

            Assert.AreEqual(staffID3, staffID3);
            Assert.AreEqual(staffModel3.name, actual[2].name);
        }
Beispiel #2
0
        private void populateStaff()
        {
            StaffTable staffTable = new StaffTable();

            StaffModel staffModelAllison = new StaffModel();

            staffModelAllison.name = "Allison";
            staffIdAllison         = staffTable.create(staffModelAllison);

            StaffModel staffModelBeth = new StaffModel();

            staffModelAllison.name = "Beth";
            staffIdBeth            = staffTable.create(staffModelAllison);

            StaffModel staffModelCarol = new StaffModel();

            staffModelCarol.name = "Carol";
            staffIdCarol         = staffTable.create(staffModelCarol);

            StaffModel staffModelDiane = new StaffModel();

            staffModelDiane.name = "Diane";
            staffIdDiane         = staffTable.create(staffModelDiane);

            StaffModel staffModelEva = new StaffModel();

            staffModelEva.name = "Eva";
            staffIdEva         = staffTable.create(staffModelDiane);
        }
Beispiel #3
0
        public void ReadAll_Create3Records_CountIs3()
        {
            //Assemble
            StaffModel staffModel1 = new StaffModel();

            staffModel1.name = "Bob";

            StaffModel staffModel2 = new StaffModel();

            staffModel2.name = "Bob2";

            StaffModel staffModel3 = new StaffModel();

            staffModel3.name = "Bob3";

            StaffTable staffTable = new StaffTable();
            int        expected   = 3;

            //Act
            int staffID1             = staffTable.create(staffModel1);
            int staffID2             = staffTable.create(staffModel2);
            int staffID3             = staffTable.create(staffModel3);
            List <StaffModel> actual = staffTable.readAll();

            //Assert
            Assert.AreEqual(expected, actual.Count);
        }
Beispiel #4
0
        public void Setup()
        {
            new DataStoreTableHelper().clearAllTables();

            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();

            programeCostId = programVarietyTable.create(programeVarietyModel);

            ProgramModel programModel = new ProgramModel();

            programModel.programVarietyId = programeCostId;

            ProgramTable programTable = new ProgramTable();

            programId = programTable.create(programModel);

            StaffModel staffModel = new StaffModel();

            staffModel.name = "Bob";

            StaffTable staffTable = new StaffTable();

            staffId = staffTable.create(staffModel);
        }
Beispiel #5
0
        public void Read_CreatedAndRead1Record_CorrectValues()
        {
            //Assemble
            StaffModel staffModel = new StaffModel();

            staffModel.name = "Bob";
            StaffTable staffTable = new StaffTable();

            //Act
            int        staffID = staffTable.create(staffModel);
            StaffModel actual  = staffTable.read(staffID);

            //Assert
            Assert.AreEqual(staffModel.name, actual.name);
        }
Beispiel #6
0
        public void Count_Created1Record_1()
        {
            //Assemble
            StaffModel staffModel = new StaffModel();

            staffModel.name = "Bob";
            int        expected   = 1;
            StaffTable staffTable = new StaffTable();

            //Act
            int staffID = staffTable.create(staffModel);
            int actual  = staffTable.count();

            //Assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #7
0
        public void Create_ValidData_StaffIDReturned()
        {
            //Assemble
            StaffModel staffModel = new StaffModel();

            staffModel.name = "Bob";
            //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;
            StaffTable staffTable = new StaffTable();

            //Act
            int actual = staffTable.create(staffModel);

            //Assert
            Assert.AreNotEqual(notCreated, actual);
        }
Beispiel #8
0
        public void Delete_CreatedDeleteAndCount1Record_0()
        {
            //Assemble
            StaffModel staffModel = new StaffModel();

            staffModel.name = "Bob";
            int        expected   = 0;
            StaffTable staffTable = new StaffTable();
            int        staffID    = staffTable.create(staffModel);

            //Act
            staffTable.delete(staffID);
            int actual = staffTable.count();

            //Assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #9
0
        public void Update_CreatedUpdateAndRead1Record_UpdatedValues()
        {
            //Assemble
            StaffModel staffModel = new StaffModel();

            staffModel.name = "Bob";
            StaffTable staffTable = new StaffTable();
            int        staffID    = staffTable.create(staffModel);

            staffModel.id   = staffID;
            staffModel.name = "Kate";

            //Act
            staffTable.update(staffModel);
            StaffModel actual = staffTable.read(staffID);

            //Assert
            Assert.AreEqual(staffModel.name, actual.name);
        }
Beispiel #10
0
        public void CreateNameConstraint_NameLengthOk_NoException()
        {
            //Assemble
            StaffTable staffTable = new StaffTable();
            StaffModel staffModel = new StaffModel();

            staffModel.name = "Bob";
            int expected = 1;
            int counter  = 0;

            //Act
            try
            {
                int id = staffTable.create(staffModel);
                counter++;
            }
            catch (Exception ex)
            {
            }

            //Assert
            Assert.AreEqual(expected, counter);
        }
Beispiel #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();
        }