public void StudentCannotEnrolWhenFullyEnrolled()
        {
            Student student = new Student { Username = "******" };
            db.Students.Add(student);

            Subject subject1 = new Subject { SubjectNumber = "1", Name = "SubjectOne", MaxEnrolment = 2 };
            Subject subject2 = new Subject { SubjectNumber = "2", Name = "SubjectTwo", MaxEnrolment = 2 };
            Subject subject3 = new Subject { SubjectNumber = "3", Name = "SubjectThree", MaxEnrolment = 2 };
            Subject subject4 = new Subject { SubjectNumber = "4", Name = "SubjectFour", MaxEnrolment = 2 };
            Subject subject5 = new Subject { SubjectNumber = "5", Name = "SubjectFive", MaxEnrolment = 2 };

            db.Subjects.Add(subject1);
            db.Subjects.Add(subject2);
            db.Subjects.Add(subject3);
            db.Subjects.Add(subject4);
            db.Subjects.Add(subject5);

            db.SaveChanges();

            Student dbStudent = db.Students.FirstOrDefault(s => s.Username == "11012592");

            Subject dbSubject1 = db.Subjects.FirstOrDefault(s => s.SubjectNumber == "1");
            Subject dbSubject2 = db.Subjects.FirstOrDefault(s => s.SubjectNumber == "2");
            Subject dbSubject3 = db.Subjects.FirstOrDefault(s => s.SubjectNumber == "3");
            Subject dbSubject4 = db.Subjects.FirstOrDefault(s => s.SubjectNumber == "4");
            Subject dbSubject5 = db.Subjects.FirstOrDefault(s => s.SubjectNumber == "5");

            _sc.Enrol(dbStudent.Id, dbSubject1.Id);
            _sc.Enrol(dbStudent.Id, dbSubject2.Id);
            _sc.Enrol(dbStudent.Id, dbSubject3.Id);
            _sc.Enrol(dbStudent.Id, dbSubject4.Id);
            _sc.Enrol(dbStudent.Id, dbSubject5.Id);

            Assert.AreEqual(4, db.Students.FirstOrDefault(s => s.Username == "11012592").EnrolledSubjects.Count);
        }
        public void CheckModelDataTypeForResultCreatePostBack()
        {
            ResultController resultController = new ResultController(ref db);

            Subject subject = new Subject() { Active = true, MaxEnrolment = 3, Name = "thisIsTestSubject", SubjectNumber = "123", Description = "" };
            db.Subjects.Add(subject);
            Student enrollingStudent = new Student() { Username = "******", FullName="TestFullName" };
            db.Students.Add(enrollingStudent);
            subject.EnrolledStudents.Add(enrollingStudent);
            db.SaveChanges();

            List<Result> results = new List<Result>();
            Subject addedSubject = (Subject)db.Subjects.FirstOrDefault(a => a.Name == "thisIsTestSubject");

            //ViewResult resultViewResult = (ViewResult)resultController.Create(results, addedSubject.Id);
        }
        public void StudentHasEnrolled()
        {
            Student student = new Student { Username = "******" };
            db.Students.Add(student);
            Subject subject = new Subject { SubjectNumber = "1", Name = "SubjectOne", MaxEnrolment = 2 };
            db.Subjects.Add(subject);
            db.SaveChanges();

            Student dbStudent = db.Students.FirstOrDefault(s => s.Username == "11012592");
            Subject dbSubject = db.Subjects.FirstOrDefault(s => s.SubjectNumber == "1");

            _sc.Enrol(dbStudent.Id, dbSubject.Id);

            Assert.AreEqual(subject.SubjectNumber, dbStudent.EnrolledSubjects.FirstOrDefault(s => s.SubjectNumber == "1").SubjectNumber);
            Assert.AreEqual(subject.Name, dbStudent.EnrolledSubjects.FirstOrDefault(s => s.SubjectNumber == "1").Name);
        }
        public void Setup()
        {
            // create subjects
            _subjects = new List<Subject>
                {
                    new Subject() {Active = true, Name = "Apple", MaxEnrolment = 3, SubjectNumber = "1000"},
                    new Subject() {Active = true, Name = "Orange", MaxEnrolment = 3, SubjectNumber = "2000"}
                };

            // subject with prereq
            var prereqAppleOrange = new List<Subject>(_subjects);
            _subjects.Add(new Subject() { Active = true, Name = "Apple and Orange", MaxEnrolment = 3, SubjectNumber = "3000", Prerequisites = prereqAppleOrange });

            // more subjects
            _subjects.Add(new Subject() {Active = true, Name = "Banana", MaxEnrolment = 3, SubjectNumber = "4000"});
            _subjects.Add(new Subject() {Active = true, Name = "Lemon", MaxEnrolment = 3, SubjectNumber = "5000"});
            _subjects.Add(new Subject() { Active = true, Name = "Lime", MaxEnrolment = 3, SubjectNumber = "6000" });

            // create student
            _student = new Student() { FullName = "StudentA", Id = 1, Username = "******" };
        }