public void Get_SurveyIdPassed_ReturnsOkObjectResult() { // Arrange var id = 2; // Act var result = _controller.GetSurvey(id); // Assert Assert.IsType <OkObjectResult>(result); }
public void Getsurvey_ShouldNotFindsurvey() { var controller = new SurveyController(GetTestSurvey()); var result = controller.GetSurvey(3); Assert.IsInstanceOfType(result, typeof(Activity)); }
public void GetSurvey_ShouldReturnCorrectSurvey() { var testSurvey = GetTestSurvey(); var controller = new SurveyController(testSurvey); var result = controller.GetSurvey(3); Assert.IsNotNull(result); Assert.AreEqual(testSurvey[0].heading, result.heading); }
public async void GetSurvey_UnknownId_ReturnsNotFoundResult() { // Arrange var mock = new Mock <ISurveyService>(); mock.Setup(s => s.GetAsync(It.IsAny <int>())).Returns((int id) => FakeServicesMethods.GetSurvey(id)); var controller = new SurveyController(mock.Object); // Act var result = await controller.GetSurvey(0); var notFoundResult = result as NotFoundResult; // Assert Assert.NotNull(notFoundResult); }
public async void GetSurvey_CorrectId_ReturnsOk() { // Arrange var mock = new Mock <ISurveyService>(); mock.Setup(s => s.GetAsync(It.IsAny <int>())).Returns((int id) => FakeServicesMethods.GetSurvey(id)); var controller = new SurveyController(mock.Object); // Act var result = await controller.GetSurvey(1); var okResult = result as OkObjectResult; // Assert Assert.NotNull(okResult); Assert.Equal(200, okResult.StatusCode); }
public async void GetSurvey_CorrectId_ReturnsRightItem() { // Arrange var mock = new Mock <ISurveyService>(); mock.Setup(s => s.GetAsync(It.IsAny <int>())).Returns((int id) => FakeServicesMethods.GetSurvey(id)); var controller = new SurveyController(mock.Object); // Act var result = await controller.GetSurvey(1); var okResult = result as OkObjectResult; // Assert var item = Assert.IsAssignableFrom <SurveyDTO>(okResult.Value); Assert.Equal(1, (okResult.Value as SurveyDTO)?.Id); }