Exemplo n.º 1
0
        public void GermanTeacherCreationWithoutReflectionTest()
        {
            FactoryMethod factory = TeacherFactory.GetFactory();
            IPerson       x       = factory.GetPersonWithoutReflection(typeof(GermanTeacher));

            Assert.AreSame(x.GetType(), typeof(GermanTeacher));
        }
 public TeacherController(ITeacherRepository repository, IServiceRepository serviceRepository,
                          IPositionRepository positionRepository, ApplicationDbContext context,
                          IGroupRepository groupRepository, IHostingEnvironment hostingEnviroment)
 {
     _repository        = repository;
     _schoolServices    = serviceRepository;
     _groupRepository   = groupRepository;
     _hostingEnviroment = hostingEnviroment;
     _proxyFactory      = new TeacherProxyFactory(context);
     _positionFactory   = new PositionFactory(positionRepository);
     _factory           = new TeacherFactory(context, _positionFactory);
 }
Exemplo n.º 3
0
        public void AddMarkOnlyToSpecifiedStudent()
        {
            // Arrange
            string studentFirstName1 = "pesho";
            string studentLastName1  = "peshov";

            string studentFirstName2 = "gosho";
            string studentLastName2  = "goshev";
            string grade             = "7";

            string teacherFirstName = "ivan";
            string teacherLastName  = "ivanov";
            string subject          = "1";
            string mark             = "2";

            IList <string> studentArgs1 = new List <string>()
            {
                studentFirstName1, studentLastName1, grade
            };
            IList <string> studentArgs2 = new List <string>()
            {
                studentFirstName2, studentLastName2, grade
            };

            IList <string> teacherArgs = new List <string>()
            {
                teacherFirstName, teacherLastName, subject
            };

            var studentFactory       = new StudentFactory();
            var createStudentCommand = new CreateStudentCommand(studentFactory);

            var teacherFactory       = new TeacherFactory();
            var createTeacherCommand = new CreateTeacherCommand(teacherFactory);

            var teacherAddMarkCommand = new TeacherAddMarkCommand();

            // Act
            createStudentCommand.Execute(studentArgs1);
            createStudentCommand.Execute(studentArgs2);
            createTeacherCommand.Execute(teacherArgs);

            var addMarkMessage = teacherAddMarkCommand.Execute(new List <string>()
            {
                "0", "0", mark
            });

            // Assert
            Assert.IsTrue(Engine.Students[0].Marks.Count == 1);
            Assert.IsTrue(Engine.Students[1].Marks.Count == 0);
        }
Exemplo n.º 4
0
        public bool enrollTeacher(TeacherFactory teaFactObj, String teacherData)
        {
            bool addTeacherStatus = true;

            Console.WriteLine("Received teacher data for processing");
            Console.WriteLine("teacherData " + teacherData);
            Teacher teacher = teaFactObj.getSingleTeacherObj(teacherData);

            Console.WriteLine("Teacher Enrollemnt Complete");
            teacher.show();
            //9,TeanineName, TeasecondName,true, #1 Hunt, 100, 8888888888
            String data = teacher.TeacherId + "," + teacher.FirstName + "," + teacher.LastName + "," + teacher.IsAvailable + "," + teacher.Address + "," + teacher.PhoneNumber;

            Console.WriteLine("data to be written is " + data);
            System.IO.File.AppendAllText("teacher.csv", data);
            return(addTeacherStatus);
        }
Exemplo n.º 5
0
        public void ReturnCorrectMessage_WithCorrectTeacherAndStudentInformation()
        {
            // Arrange
            string studentFirstName = "pesho";
            string studentLastName  = "peshov";
            string grade            = "7";

            string teacherFirstName = "ivan";
            string teacherLastName  = "ivanov";
            string subject          = "1";
            string mark             = "2";
            string subjectEnum      = "English";

            IList <string> studentArgs = new List <string>()
            {
                studentFirstName, studentLastName, grade
            };
            IList <string> teacherArgs = new List <string>()
            {
                teacherFirstName, teacherLastName, subject
            };

            var studentFactory       = new StudentFactory();
            var createStudentCommand = new CreateStudentCommand(studentFactory);

            var teacherFactory       = new TeacherFactory();
            var createTeacherCommand = new CreateTeacherCommand(teacherFactory);

            var    teacherAddMarkCommand = new TeacherAddMarkCommand();
            string expectedMessage       = $"Teacher {teacherFirstName} {teacherLastName} added mark {mark} to student {studentFirstName} {studentLastName} in {subjectEnum}.";

            // Act
            createStudentCommand.Execute(studentArgs);
            createTeacherCommand.Execute(teacherArgs);

            var addMarkMessage = teacherAddMarkCommand.Execute(new List <string>()
            {
                "0", "0", mark
            });

            // Assert
            //Assert.IsTrue(addMarkMessage.Contains($"{teacherFirstName} {teacherLastName}") && addMarkMessage.Contains($"{studentFirstName} {studentLastName}"));
            Assert.IsTrue(addMarkMessage == expectedMessage);
        }
        public static void demo()
        {
            EnrollmentRulesFactory enrollFactoryObj         = factory.getEnrollmentRuleObj();
            List <String>          enrollmentRegulationList = new List <String>();

            //minAge, maxAge, num of Students, num of Teachers, groupSize
            enrollmentRegulationList.Add("6,12,4,1,3");
            enrollmentRegulationList.Add("13,24,5,1,3");
            enrollmentRegulationList.Add("25,35,6,1,3");
            enrollmentRegulationList.Add("36,47,8,1,3");
            enrollmentRegulationList.Add("48,59,12,1,2");
            enrollmentRegulationList.Add("60,100,15,1,2");
            DayCare day = factory.getDayCareObj();

            day.setEnrollmentruleList(enrollFactoryObj.getRuleObj(enrollmentRegulationList));
            List <String> rulesList = new List <String>();
            String        firstLine = "Age Group,\tgroupSize,\tratio,\tmaxGroups/Class";

            rulesList.Add(firstLine);
            foreach (EnrollmentRules EnrollmentRules in day.getEnrollmentruleList())
            {
                String rule = "" + EnrollmentRules.MinAge + "-" + EnrollmentRules.MaxAge + ",\t\t\t"
                              + EnrollmentRules.GroupSize + ", \t\t\t" + EnrollmentRules.Ratio + ", \t\t\t" + EnrollmentRules.MaxGroup;

                rulesList.Add(rule);
            }

            System.IO.File.WriteAllLines(enrollmentRulesFileName, rulesList);
            createDayCareImmunizationRules();

            //Teacher Factory object initialization
            TeacherFactory teacherFactoryObj = TeacherFactory.getTeacherFactoryObj();
            List <String>  teacher_data      = System.IO.File.ReadLines(teacherFileName).ToList();

            Console.WriteLine("Student File read successfully");
            day.setTeacherList(teacherFactoryObj.getTeacherObj(teacher_data));

            //Student Factory object inittialization
            StudentFactory studentFactoryObj = StudentFactory.getObj();
            List <String>  student_data      = System.IO.File.ReadLines(studentFileName).ToList();

            Console.WriteLine("Student File read successfully");
            List <Student> studentList = studentFactoryObj.initStudentObj(student_data, false);

            day.enrollStudent(studentList);

            List <String> immunization_data = System.IO.File.ReadLines(immunizationFileName).ToList();

            day.mapStudentIDToImmunizationData(immunization_data, studentList, day.getImmunizationFactoryInstance());

            foreach (Classroom classroom in day.getClassroomList())
            {
                //System.out.print("\nClassID:" + classroom.classroomID + "\tAge group:" + classroom.getEnrollmentRule().getMinAge() + "-" + classroom.getEnrollmentRule().getMaxAge() + "months");
                foreach (Group group in classroom.getGroupList())
                {
                    //System.out.print("\n\tGroupID:" + group.getGroupID() + "   Teacher Assigned:" + group.getTeacher().getFirstName() + "\n");
                    foreach (Student student in group.getStudentList())
                    {
                        if (student.getImmunizationRecord() != null)
                        {
                            foreach (Immunization im in student.getImmunizationRecord())
                            {
                                im.checkImmunizationStatus(student.DateOfBirth);
                            }
                        }
                    }
                }
            }
        }
 public void setTeacherFactoryObj(TeacherFactory teacherFactoryObj)
 {
     this.teacherFactoryObj = teacherFactoryObj;
 }