protected void Register_Prof(object sender, EventArgs e) { teacher = new Teacher(); teacher.Name = name.Value; teacher.LastName = last_name.Value; teacher.Email = email.Value; teacher.Password = password.Value; teacher.Phone = telf.Value; teacher.Country = country.Value; fec_nac.Value = fec_nac.Value + " 12:00:00"; DateTime fec_nac_ = DateTime.Parse(fec_nac.Value, CultureInfo.GetCultureInfo("en-US")); teacher.BirthDate = Convert.ToDateTime(fec_nac_); CreateTeacherCommand cmd = new CreateTeacherCommand(teacher); cmd.Execute(); if (password.Value.Equals(conf_pwd.Value)) { if (teacher.Code == 200) { ClientScript.RegisterClientScriptBlock(this.GetType(), "random", "alertme_succ()", true); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "random", "alertme()", true); fec_nac.Value = fec_nac_.Date.ToString("MM/dd/yyyy"); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "random", "alertme_pwd()", true); fec_nac.Value = fec_nac_.Date.ToString("MM/dd/yyyy"); } }
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); }
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 void TestExecute_PassValidParameters_ShouldCallFactoryCreateTeacherCorrectly() { // Arrange var parameters = new string[] { "Pesho", " Peshev", "11" }; var teacher = new Teacher("Foo", "Bar", Subject.Bulgarian); var mockedFactory = new Mock <ITeacherFactory>(); mockedFactory.Setup(x => x.CreateTeacher(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Subject>())) .Returns(teacher); var mockedService = new Mock <ITeacherService>(); mockedService.Setup(s => s.AddTeacher(It.IsAny <Teacher>())).Returns(1); var command = new CreateTeacherCommand(mockedFactory.Object, mockedService.Object); // Act command.Execute(parameters); // Assert mockedFactory.Verify(x => x.CreateTeacher(parameters[0], parameters[1], (Subject)int.Parse(parameters[2])), Times.Once); }