public void Get_ReturnsAllStudies() { // Arrange var mock = new Mock <IStudyManager>(); mock.Setup(p => p.GetAll()).Returns(studiesTest); StudyController studyController = new StudyController(mock.Object); // Act var result = studyController.Get(); // Assert Assert.AreEqual(2, result.Value.Count()); }
public void Get_ReturnsStudyByID() { // Arrange var mock = new Mock <IStudyManager>(); mock.Setup(p => p.GetStudyByGUID("abc")).Returns(study1); StudyController studyController = new StudyController(mock.Object); // Act var result = studyController.Get("abc"); // Assert Assert.AreEqual("study1", result.Value.StudyId); }
public async Task Get_given_nonexisting_id_returns_NotFound() { // Arrange var repository = new Mock <IStudyRepository>(); repository.Setup(r => r.FindAsync(11)).ReturnsAsync(default(StudyDTO)); var controller = new StudyController(repository.Object, log.Object); // Act var result = await controller.Get(11); // Assert Assert.IsType <NotFoundResult>(result); }
public async Task Get_given_id_returns_Ok_with_study() { // Arrange var study = new StudyDTO(); var repository = new Mock <IStudyRepository>(); repository.Setup(r => r.FindAsync(11)).ReturnsAsync(study); var controller = new StudyController(repository.Object, log.Object); // Act var result = await controller.Get(11) as OkObjectResult; // Assert Assert.Equal(study, result.Value); }
public async Task Get_returns_Ok_with_studies() { // Arrange var studies = new StudyDTO[0]; var repository = new Mock <IStudyRepository>(); repository.Setup(r => r.ReadAsync()).ReturnsAsync(studies); var controller = new StudyController(repository.Object, log.Object); // Act var result = await controller.Get() as OkObjectResult; // Assert Assert.Equal(studies, result.Value); }