public async Task ShouldListAllStudents() { var mockRepo = new Mock <IDataRepository>(); mockRepo.Setup(repo => repo.StudentListAsync()). ReturnsAsync(GetStudentData()); StudentsController controller = new StudentsController(mockRepo.Object); var result = await controller.GetAllRegisteredStudents(); Assert.IsInstanceOfType(result.Result, typeof(OkObjectResult)); var okResult = result.Result as OkObjectResult; var students = okResult.Value as List <Student>; Assert.AreEqual(2, students.Count); Assert.AreEqual("mwj7", students[0].Uid); Assert.AreEqual("Morgan", students[0].Forename); Assert.AreEqual("Jones", students[0].Surname); Assert.AreEqual("dop2", students[1].Uid); Assert.AreEqual("Dominic", students[1].Forename); Assert.AreEqual("Parr", students[1].Surname); }