Beispiel #1
0
        public static void MyClassInitialize(TestContext testContext)
        {
            testUniver = new University("Test Uni");

            testGroup = new Group("TestGroup");
            testGroup.AddStudent(new Student("Mr. Brilliant"));
            testGroup.AddStudent(new Student("Mr. Diamond"));
            testGroup.AddStudent(new Student("Mr. Carbone"));
            testUniver.AddGroup(testGroup);

            testTeacher = new Teacher("Mr. Smartpants");

            testCourse = new Course("Very hard course");
            testUniver.AddCourse(testCourse);
            testTeacher.AddCourse(testCourse);
        }
Beispiel #2
0
        public void SerializeGroup()
        {
            Group srcGroup = new Group("Test Group");
            Student stud = new Student("Mr. Stud");
            srcGroup.AddStudent(stud);

            string tempFileName = Path.GetTempFileName();
            FileStream fs = File.Create(tempFileName);
            XmlSerializer ser = new XmlSerializer(typeof(Group));
            ser.Serialize(fs, srcGroup);
            fs.Close();
            fs = File.OpenRead(tempFileName);
            Group newGroup = (Group)ser.Deserialize(fs);
            fs.Close();
            File.Delete(tempFileName);

            Assert.AreEqual(srcGroup.Name, newGroup.Name, "Names expected to be equal");
            Assert.AreEqual(srcGroup.ID, newGroup.ID, "IDs expected to be equal");
            Assert.AreEqual(srcGroup.Students.Count(), newGroup.Students.Count(), "Something wrong with studList serialization");

            Student savedMrStud = newGroup.Students.ElementAt(0);
            StringAssert.Equals(stud.Name, savedMrStud.Name);

            Storage.Data.Students.RemoveItem(stud);
        }
Beispiel #3
0
        public void StudentsOfGroup()
        {
            Group tempGroup = new Group("TestGroup");
            Student stud1 = new Student("Mr. First");
            Student stud2 = new Student("Mr. Second");
            Student stud3 = new Student("Mr. Third");
            tempGroup.AddStudent(stud1);
            Storage.Data.Students.AddItem(stud2);
            tempGroup.AddStudent(stud3);

            var resEnum = tempGroup.Students;
            var arr = resEnum.ToArray();
            Assert.AreEqual(2, arr.Length, "Two students expected to be in the group");
            Assert.AreEqual(stud1.ID, arr[0].ID, "There should be stud1");
            Assert.AreEqual(stud3.ID, arr[1].ID, "There should be stud3");

            Storage.Data.Students.RemoveItem(stud1);
            Storage.Data.Students.RemoveItem(stud2);
            Storage.Data.Students.RemoveItem(stud3);
        }