/** * <summary>This method stores valid student data into a Student object, which is then stored within the AcademicYear object.</summary> * * <param name="ay">The AcademicYear object to have a student added to it.</param> * <param name="array">The array, representing items on a line of the raw data text file.</param> */ public static void StoreStudentDetails(AcademicYear ay, string[] array) { // IF statement checks that the AcademicYear object is not null, and if the array is not null or empty. if (ay != null && (array != null || array.Length > 0)) { // A new Student object is created with valid parameters and stored within the AcademicYear object. ay.AddStudentToYear(new Student(array[0].Trim(), HelperMethods.CapitaliseFirstLetterOfEachWord(array[1]), HelperMethods.CapitaliseFirstLetterOfEachWord(array[2]), int.Parse(array[3]), CapitaliseFirstLetter(array[4], false) )); } }
public void AddStudentToYearTest() { year.AddStudentToYear(new Student("6000", "John", "Krascinski", 11, "Peach")); year.AddStudentToYear(new Student("6001", "Rainn", "Wilson", 11, "Blue")); year.AddStudentToYear(new Student("6002", "Jenna", "Fischer", 11, "Crimson")); Assert.AreEqual(3, year.GetStudents.Count); }