public void AddStudent_ShouldAddStudentToListOfStudent()
        {
            var expectedId    = 10;
            var mockedStudent = new Mock <IStudent>();

            SchoolSystemEngine.AddStudent(expectedId, mockedStudent.Object);

            Assert.AreSame(SchoolSystemEngine.Students[expectedId], mockedStudent.Object);
        }
        public void AddStudent_WhenStudentIsNull_ShouldThrowArgumentNullException()
        {
            var      id          = 100;
            IStudent nullStudent = null;

            var ex = Assert.Throws <ArgumentNullException>(() => SchoolSystemEngine.AddStudent(id, nullStudent));

            StringAssert.Contains("cannot be null or empty", ex.Message);
        }
        public void AddStudent_WhenIdIsInvalid_ShouldThrowArgumentOutOfRangeException()
        {
            var invalidID     = -1;
            var mockedStudent = new Mock <IStudent>();

            var ex = Assert.Throws <ArgumentOutOfRangeException>(() => SchoolSystemEngine.AddStudent(invalidID, mockedStudent.Object));

            StringAssert.Contains("cannot be less than 0!", ex.Message);
        }
        public void RemoveStudent_ShouldRemoveStudentInStudents()
        {
            var expectedId    = 11;
            var mockedStudent = new Mock <IStudent>();

            SchoolSystemEngine.AddStudent(expectedId, mockedStudent.Object);

            SchoolSystemEngine.RemoveStudent(expectedId);

            Assert.IsFalse(SchoolSystemEngine.Students.ContainsKey(expectedId));
        }
예제 #5
0
        /// <summary>
        /// Executes the CreateStudentCommand and returns the result.
        /// </summary>
        /// <param name="parameters">The Student parameters.</param>
        /// <returns>A string describing the new student.</returns>
        public string Execute(IList <string> parameters)
        {
            var firstName = parameters[0];
            var lastName  = parameters[1];
            var grade     = (Grade)int.Parse(parameters[2]);

            var studentToAdd = new Student(firstName, lastName, grade);

            SchoolSystemEngine.AddStudent(id, studentToAdd);

            return($"A new student with name {studentToAdd.FirstName} {studentToAdd.LastName}, grade {studentToAdd.Grade} and ID {id++} was created.");
        }