Exemplo n.º 1
0
        public void AddNewStudentToSubject()
        {
            Subject subject = new Subject(1, "Logic");
            Student student = new Student("Jose", "Lopez", "1234567-8");

            subject.AddStudent(student);
            Assert.IsNotNull(FindStudentByDocument(subject.Students, student.GetDocumentNumber()));
        }
        public void AddStudentToSystem()
        {
            IStudentLogic studentOperations = DummyProvider.GetInstance.GetStudentOperations();

            Student newStudent = Utility.CreateRandomStudent();

            newStudent.Subjects          = new List <Subject>();
            newStudent.HavePickUpService = false;
            newStudent.StudentNumber     = 1;
            studentOperations.AddStudent(newStudent);

            Assert.IsNotNull(Utility.FindStudentOnSystem(newStudent.GetDocumentNumber()));
        }
        public void CreateStudentWithParameters()
        {
            string         expectedName           = "Luis";
            string         expectedLastName       = "Suarez";
            string         expectedDocumentNumber = "1234567-8";
            int            expectedStudentNumber  = 0;
            List <Subject> expectedSubjects       = new List <Subject>();

            Student student = new Student(expectedName, expectedLastName, expectedDocumentNumber);

            Assert.AreEqual(expectedName, student.GetName());
            Assert.AreEqual(expectedLastName, student.GetLastName());
            Assert.AreEqual(expectedDocumentNumber, student.GetDocumentNumber());
            Assert.AreEqual(expectedStudentNumber, student.GetStudentNumber());

            List <Subject> actualSubjects = student.GetSubjects();

            Assert.IsTrue(Utility.CompareLists(actualSubjects, expectedSubjects));
        }
        public void DoNotAllowToAddDuplicateStudentToSystem()
        {
            try
            {
                IStudentLogic studentOperations = DummyProvider.GetInstance.GetStudentOperations();

                Student firstStudent = Utility.CreateRandomStudent();
                firstStudent.StudentNumber = 1;

                Student secondStudent = new Student(firstStudent.GetName(), firstStudent.GetLastName(), firstStudent.GetDocumentNumber());
                secondStudent.StudentNumber = 2;

                studentOperations.AddStudent(firstStudent);
                studentOperations.AddStudent(secondStudent);

                Assert.Fail();
            }
            catch (CoreException ex)
            {
                Assert.IsTrue(ex.Message.Equals("Student already exists."));
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }