public void TestIfAddStudentWithExistingIdThrowsException() { Exception ex = Assert.Throws <Exception>(() => coursesService .AddStudentToCourse(schools[0], "Math", new Student { Id = 10023, Name = "Peter" })); Assert.That(ex.Message, Is.EqualTo("Student id is not unique")); }