public async Task PostPoint_Should_ReturnOk() { // Arrange var adapterMock = new Mock <ITodoPointAdapter>(); var loggerMock = new Mock <ILogger <PointController> >(); var testPoint = new TodoPointViewModel { PointId = 3, TodoId = 2, Description = "test point 3" }; adapterMock.Setup(x => x.AddPoint(testPoint)).Returns(Task.FromResult(testPoint)); var controller = new PointController(adapterMock.Object, loggerMock.Object); // Act var result = await controller.PostPoint(testPoint); // Assert var okResult = Assert.IsAssignableFrom <OkObjectResult>(result); var returnValue = Assert.IsAssignableFrom <TodoPointViewModel>(okResult.Value); Assert.Equal(testPoint.Description, returnValue.Description); }
public async Task PostPoint_Should_ReturnBadRequest() { // Arrange var adapterMock = new Mock <ITodoPointAdapter>(); var loggerMock = new Mock <ILogger <PointController> >(); var controller = new PointController(adapterMock.Object, loggerMock.Object); // Act var result = await controller.PostPoint(null); // Assert var actionResult = Assert.IsAssignableFrom <ActionResult>(result); var returnValue = Assert.IsAssignableFrom <BadRequestObjectResult>(actionResult); Assert.Equal("Point object is null", returnValue.Value); }