public void TestGetStudent() { ExpectedStudents expectedStudents = new ExpectedStudents(); List <Student> expected = expectedStudents.GetStudents(); string expectedSsn = expected[0].SSN; string expectedName = expected[0].name; string expectedSurname = expected[0].surname; ObjectResult result = (ObjectResult)studentsController.GetStudent(expectedSsn).Result; int?statusCode = result.StatusCode; Assert.Equal(200, statusCode); StudentAPI student = (StudentAPI)result.Value; Assert.True(student.name == expectedName && student.surname == expectedSurname); }
public void TestGetStudents() { ExpectedStudents expectedStudents = new ExpectedStudents(); List <Student> expected = expectedStudents.GetStudents(); ObjectResult result = (ObjectResult)studentsController.Get().Result; int?statusCode = result.StatusCode; Assert.Equal(200, statusCode); List <Student> actual = (List <Student>)result.Value; Assert.Equal(expected.Count, actual.Count); for (int i = 0; i < expected.Count; ++i) { Assert.Equal(expected[i].SSN, actual[i].SSN); } }
public void TestGetStudentGrades() { ExpectedStudents expectedStudents = new ExpectedStudents(); string studentSsn = expectedStudents.GetStudents()[0].SSN; ExpectedGrades expectedGrades = new ExpectedGrades(); List <StudentGrades> expected = expectedGrades.ShowStudentGrades(studentSsn); ObjectResult result = (ObjectResult)gradesController.GetStudentGrades(studentSsn).Result; int?statusCode = result.StatusCode; Assert.Equal(200, statusCode); List <StudentGrades> actual = (List <StudentGrades>)result.Value; Assert.Equal(expected.Count, actual.Count); for (int i = 0; i < expected.Count; ++i) { Assert.True(expected[i].course == actual[i].course && expected[i].grade == actual[i].grade); } }