本文整理汇总了C#中Course.AddStudentToCourse方法的典型用法代码示例。如果您正苦于以下问题:C# Course.AddStudentToCourse方法的具体用法?C# Course.AddStudentToCourse怎么用?C# Course.AddStudentToCourse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course.AddStudentToCourse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IfTryToAddExistingStudentToCourseThrowInvalidOperationException
public void IfTryToAddExistingStudentToCourseThrowInvalidOperationException()
{
string courseName = "Hight Quality Code";
string studentName = "Ivan Ivanov";
int studentId = 10000;
Course course = new Course(courseName);
Student student = new Student(studentName, studentId);
course.AddStudentToCourse(student);
course.AddStudentToCourse(student);
}
示例2: RemoveStudentFromCourse_ShouldThrowException_WhenAddMoreThanThirtyStudents
public void RemoveStudentFromCourse_ShouldThrowException_WhenAddMoreThanThirtyStudents()
{
// Arrange and Act
var peshoStudent = new Student("Pesho", 54342);
var course = new Course();
for (int i = 0; i <= 33; i++)
{
course.AddStudentToCourse(peshoStudent);
}
}
示例3: AddStudentToCourse_ShouldAddStudentToCourseCorrectly
public void AddStudentToCourse_ShouldAddStudentToCourseCorrectly()
{
// Arrange
var peshoStudent = new Student("Pesho",54342);
var course = new Course();
// Act
course.AddStudentToCourse(peshoStudent);
// Assert
Assert.AreEqual(1, course.Students.Count);
}
示例4: IfStudentsListIsFullThrowArgumentOutOfRangeException
public void IfStudentsListIsFullThrowArgumentOutOfRangeException()
{
string courseName = "Hight Quality Code";
string studentName = "Ivan Ivanov";
int studentId = 10000;
Course course = new Course(courseName);
for (int i = 0; i <= 30; i++)
{
Student student = new Student(studentName + i, studentId + i);
course.AddStudentToCourse(student);
}
}
示例5: Main
static void Main(string[] args)
{
Student student1 = new Student();
student1.StudentFirstName = "John";
student1.StudentLastName = "Lennon";
student1.StudentBirthDate = DateTime.Parse("19/02/1945");
student1.StudentCity = "Liverpool";
student1.StudentCountry = "United Kingdom";
student1.AddGrades(10, 9.8, 8.7, 9, 8);
Student student2 = new Student();
student2.StudentFirstName = "Paul";
student2.StudentLastName = "Mcartney";
student2.StudentBirthDate = DateTime.Parse("10/06/1951");
student2.StudentCity = "Liverpool";
student2.StudentCountry = "United Kingdom";
student2.AddGrades(8, 10, 9.9, 10, 9.5);
Student student3 = new Student();
student3.StudentFirstName = "George";
student3.StudentLastName = "Harrison";
student3.StudentBirthDate = DateTime.Parse("22/09/1956");
student3.StudentCity = "Manchester";
student3.StudentCountry = "United Kingdom";
student3.AddGrades(9, 10, 10, 10, 8.5);
Course programmingWithC = new Course();
programmingWithC.Name = "Programming with C #";
programmingWithC.AddStudentToCourse(student1);
programmingWithC.AddStudentToCourse(student2);
programmingWithC.AddStudentToCourse(student3);
Console.WriteLine("The {0} course contains {1} student(s)", programmingWithC.Name, programmingWithC.StudentCourseCount.ToString());
Console.WriteLine("---------------------------------");
Console.WriteLine("Students in {0} course:", programmingWithC.Name);
programmingWithC.ListStudents();
Console.WriteLine("---------------------------------");
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Press any key to quit");
Console.ReadKey();
}
示例6: IfTryToAddNullStudentToCourseThrowArgumentNullException
public void IfTryToAddNullStudentToCourseThrowArgumentNullException()
{
string name = "Hight Quality Code";
Student student = null;
Course course = new Course(name);
course.AddStudentToCourse(student);
}
示例7: StudentShouldBeRemovedInCourseList
public void StudentShouldBeRemovedInCourseList()
{
string courseName = "Hight Quality Code";
string studentName = "Ivan Ivanov";
int studentId = 10000;
Course course = new Course(courseName);
Student student = new Student(studentName, studentId);
course.AddStudentToCourse(student);
course.RemoveStudentFromCourse(student);
Assert.AreEqual(0, course.Students.Count);
}
示例8: StudentShouldBeAddetInCourseList
public void StudentShouldBeAddetInCourseList()
{
string courseName = "Hight Quality Code";
string studentName = "Ivan Ivanov";
int studentId = 10000;
Course course = new Course(courseName);
Student student = new Student(studentName, studentId);
course.AddStudentToCourse(student);
Assert.AreSame(student, course.Students.First());
}