public void TestMethod_InputMoreMasterStudents()
        {
            Faculty testFax = new Faculty("ETF");

            /* Container class "Faculty" has default
             * start bachelor index value at 17000.
             * Two of the additional students added
             * to the list should have indices
             * "17001" and "17002".
             */
            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1), "ETF Sarajevo");
            string index = testFax.ListOfMasterStudents[0].IndexIDNumber;

            Assert.AreEqual(index, "100/17000");

            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111112", new DateTime(2005, 1, 1), "ETF Sarajevo");
            index = testFax.ListOfMasterStudents[1].IndexIDNumber;
            Assert.AreEqual(index, "101/17001");

            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111113", new DateTime(2005, 1, 1), "ETF Sarajevo");
            index = testFax.ListOfMasterStudents[2].IndexIDNumber;
            Assert.AreEqual(index, "102/17002");

            CollectionAssert.AllItemsAreUnique(testFax.ListOfMasterStudents);
            CollectionAssert.AllItemsAreUnique(testFax.ListOfAllStudent);
            CollectionAssert.AllItemsAreNotNull(testFax.ListOfMasterStudents);
            CollectionAssert.IsSubsetOf(testFax.ListOfMasterStudents, testFax.ListOfAllStudent);
        }
Beispiel #2
0
        public void DataDrivenTest_CreatingMasterFromDatabase()
        {
            masterStudent test = new masterStudent(Convert.ToString(TestContext.DataRow["Name"]), Convert.ToString(TestContext.DataRow["Surname"]), Convert.ToDateTime(TestContext.DataRow["DateOfBirth"]), Convert.ToString(TestContext.DataRow["IDNumber"]), Convert.ToString(TestContext.DataRow["IDIndexNumber"]), Convert.ToDateTime(TestContext.DataRow["EndOfPrevEd"]), Convert.ToString(TestContext.DataRow["PlaceOfPrevEd"]));

            Faculty testFax = new Faculty("ETF");

            testFax.AddMasterStudent(Convert.ToString(TestContext.DataRow["Name"]), Convert.ToString(TestContext.DataRow["Surname"]), Convert.ToDateTime(TestContext.DataRow["DateOfBirth"]), Convert.ToString(TestContext.DataRow["IDNumber"]), Convert.ToDateTime(TestContext.DataRow["EndOfPrevEd"]), Convert.ToString(TestContext.DataRow["PlaceOfPrevEd"]));
            Assert.IsTrue(test.IDnumber == testFax.FindStudent(Convert.ToString(TestContext.DataRow["IDNumber"])));
        }
        public void TestMethod_FacultyBalance()
        {
            Faculty testFax = new Faculty("ETF");

            testFax.AddBachelorStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1));
            testFax.AddBachelorStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111112", new DateTime(2005, 1, 1));
            testFax.AddBachelorStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111113", new DateTime(2005, 1, 1));
            double expenditures = testFax.Balance;

            Assert.AreEqual(expenditures, 9000 * 3);

            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111114", new DateTime(2005, 1, 1), "ETF Sarajevo");
            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111115", new DateTime(2005, 1, 1), "ETF Sarajevo");
            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111116", new DateTime(2005, 1, 1), "ETF Sarajevo");
            expenditures = testFax.Balance;
            Assert.AreEqual(expenditures, (9000 * 3) + (11000 * 3));

            Assert.AreEqual(testFax.FLAG, 1);
        }
        public void TestMethod_InputMasterStudent()
        {
            Faculty testFax = new Faculty("ETF");

            /* We are sending instance of bachelor student
             * without index number because container
             * class "Faculty" is generating index for us.
             */
            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1), "ETF Sarajevo");
        }
        public void TestMethod_DeletingMasterStudent_ByID()
        {
            Faculty testFax = new Faculty("ETF");

            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1), "ETF Sarajevo");
            Assert.AreEqual(testFax.ListOfAllStudent.Count, 1);
            Assert.AreEqual(testFax.ListOfMasterStudents.Count, 1);

            testFax.deleteStudentByID("1111111111111");
            Assert.AreEqual(testFax.ListOfAllStudent.Count, 0);
            Assert.AreEqual(testFax.ListOfMasterStudents.Count, 0);
        }
        public void TestMethod_InputMoreMasterStudents_SameID()
        {
            Faculty testFax = new Faculty("ETF");

            /* We are sending instance of bachelor student
             * without index number because container
             * class "Faculty" is generating index for us.
             */
            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1), "ETF Sarajevo");
            string index = testFax.ListOfMasterStudents[0].IndexIDNumber;

            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1), "ETF Sarajevo");
            index = testFax.ListOfMasterStudents[1].IndexIDNumber;

            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1), "ETF Sarajevo");
            index = testFax.ListOfMasterStudents[2].IndexIDNumber;

            /* Exception should be thrown
             * because all instances of students
             * have the same ID.
             */
        }
        public void TestMethod_master_SetterInfoValidity()
        {
            Faculty testFax = new Faculty("ETF");

            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1), "ETF Sarajevo");

            string index = testFax.ListOfMasterStudents[0].IndexIDNumber;

            Assert.AreEqual(index, "100/17000");

            testFax.ListOfMasterStudents[0].Name = "changedName";
            string name = testFax.ListOfMasterStudents[0].Name;

            Assert.AreEqual(name, "changedName");

            testFax.ListOfMasterStudents[0].Surname = "changedSurname";
            string surname = testFax.ListOfMasterStudents[0].Surname;

            Assert.AreEqual(surname, "changedSurname");

            testFax.ListOfMasterStudents[0].DateOfBirth = new DateTime(1994, 1, 1);
            DateTime birth = testFax.ListOfMasterStudents[0].DateOfBirth;

            Assert.AreEqual(birth, new DateTime(1994, 1, 1));

            testFax.ListOfMasterStudents[0].IDnumber = "2222222222222";
            string ID = testFax.ListOfMasterStudents[0].IDnumber;

            Assert.AreEqual(ID, "2222222222222");

            testFax.ListOfMasterStudents[0].EndOfPreviousEducation = new DateTime(2006, 1, 1);
            DateTime endOfPrevEd = testFax.ListOfMasterStudents[0].EndOfPreviousEducation;

            Assert.AreEqual(endOfPrevEd, new DateTime(2006, 1, 1));

            testFax.ListOfMasterStudents[0].PlaceOfPreviousEd = "changedPlace";
            string exEd = testFax.ListOfMasterStudents[0].PlaceOfPreviousEd;

            Assert.AreEqual(exEd, "changedPlace");

            /* Setting new list of passed courses for the student */
            List <Course> passed = new List <Course>();

            testFax.ListOfMasterStudents[0].PassedCourses = passed;
            List <Course> passedChanged = new List <Course>();

            testFax.ListOfMasterStudents[0].PassedCourses = passedChanged;
            Assert.AreEqual(passedChanged, testFax.ListOfMasterStudents[0].PassedCourses);
        }
        public void TestMethod_master_GeneratedIndexValidity()
        {
            Faculty testFax = new Faculty("ETF");

            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1), "ETF Sarajevo");
            string index = testFax.ListOfMasterStudents[0].IndexIDNumber;

            /* Container class "Faculty" has default
             * start master index value at 100/17000
             */
            Assert.AreEqual(index, "100/17000");
            StringAssert.Contains(index, "/");
            StringAssert.Matches(index, MASTER_INDEX_ID_NUMBER_PATTERN);
            StringAssert.EndsWith(index, "17000");
        }
        public void TestMethod_master_GetterInfoValidity()
        {
            Faculty testFax = new Faculty("ETF");

            /* We are sending instance of bachelor student
             * without index number because container
             * class "Faculty" is generating index for us.
             */
            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1), "ETF Sarajevo");
            string index = testFax.ListOfMasterStudents[0].IndexIDNumber;

            Assert.AreEqual(index, "100/17000");

            string name = testFax.ListOfMasterStudents[0].Name;

            Assert.AreEqual(name, "name");

            string surname = testFax.ListOfMasterStudents[0].Surname;

            Assert.AreEqual(surname, "surname");

            DateTime birth = testFax.ListOfMasterStudents[0].DateOfBirth;

            Assert.AreEqual(birth, new DateTime(1990, 1, 1));

            string ID = testFax.ListOfMasterStudents[0].IDnumber;

            Assert.AreEqual(ID, "1111111111111");

            DateTime endOfPrevEd = testFax.ListOfMasterStudents[0].EndOfPreviousEducation;

            Assert.AreEqual(endOfPrevEd, new DateTime(2005, 1, 1));

            string exEdplace = testFax.ListOfMasterStudents[0].PlaceOfPreviousEd;

            Assert.AreEqual(exEdplace, "ETF Sarajevo");

            /* Adding passed courses for the student */
            List <Course> passed = new List <Course>();

            testFax.ListOfMasterStudents[0].PassedCourses = passed;
            Assert.AreEqual(passed, testFax.ListOfMasterStudents[0].PassedCourses);
        }
        public void TestMethod_InputMasterStudent_ifBachelorStudentExists()
        {
            Faculty testFax = new Faculty("ETF");

            /* We are adding bachelor student */
            testFax.AddBachelorStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1));
            /* List of all bachelor students and all students should be 1. */
            Assert.AreEqual(testFax.ListOfBachelorStudents.Count, 1);
            Assert.AreEqual(testFax.ListOfAllStudent.Count, 1);
            /* Index number of entered student should be 17000 */
            Assert.AreEqual(testFax.ListOfBachelorStudents[0].IndexIDNumber, "17000");

            /* We are adding master student with same person ID! */
            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2005, 1, 1), "ETF Sarajevo");
            /* Now, there should be 0 bachelor students and 1 master student in container class */
            Assert.AreEqual(testFax.ListOfBachelorStudents.Count, 0);
            Assert.AreEqual(testFax.ListOfMasterStudents.Count, 1);
            /* Master student index should be his last index (17000) with added 100 as generated by the container class */
            Assert.AreEqual(testFax.ListOfMasterStudents[0].IndexIDNumber, "100/17000");
            /* List of all students should remain at 1 */
            Assert.AreEqual(testFax.ListOfAllStudent.Count, 1);
        }
        public void TestMethod_mStudent_invalidDateOfPreviousEd() // Invalid date of previous education
        {
            Faculty testFax = new Faculty("ETF");

            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2020, 1, 1), "ETF Sarajevo");
        }
        public void TestMethod_mStudent_invalidPersonId_numeric() // Invalid person ID - numeric (must be 13 letters)
        {
            Faculty testFax = new Faculty("ETF");

            testFax.AddMasterStudent("name", "surname", new DateTime(1990, 1, 1), "11111111111a#", new DateTime(2016, 1, 1), "ETF Sarajevo");
        }
        public void TestMethod_mStudent_invalidBirthDate() // Invalid birth date
        {
            Faculty testFax = new Faculty("ETF");

            testFax.AddMasterStudent("name", "surname", new DateTime(2017, 1, 1), "1111111111111", new DateTime(2016, 1, 1), "ETF Sarajevo");
        }
        public void TestMethod_mStudent_invalidSurname() // Invalid surname
        {
            Faculty testFax = new Faculty("ETF");

            testFax.AddMasterStudent("name", "surn@@ame", new DateTime(1990, 1, 1), "1111111111111", new DateTime(2016, 1, 1), "ETF Sarajevo");
        }