public async Task UpdateCameraActivity_WhenCalled_ShouldCallHelper() { //Arrange var expectedActivity = false; var expectedDataModel = new UpdateCameraActivityDataModel() { IsActive = expectedActivity }; var fakeCameraInfoHelper = A.Fake <ICameraInfoHelper>(); var expectedId = 0; var expectedCameraInfo = new CameraInfo() { Id = expectedId }; A.CallTo(() => fakeCameraInfoHelper.UpdateCameraActivity(expectedId, expectedActivity)) .Returns(expectedCameraInfo); var cameraController = new CameraInfoController() { CameraInfoHelper = fakeCameraInfoHelper, Request = new HttpRequestMessage() }; //Act var result = cameraController.UpdateCameraActivity(expectedId, expectedDataModel); //Assert A.CallTo(() => fakeCameraInfoHelper.UpdateCameraActivity(expectedId, expectedActivity)) .MustHaveHappenedOnceExactly(); var httpResponse = await result.ExecuteAsync(new CancellationToken()); var jsonContent = await httpResponse.Content.ReadAsStringAsync(); var expectedJson = JsonConvert.SerializeObject(expectedCameraInfo); jsonContent.ShouldBe(expectedJson); }
public IHttpActionResult UpdateCameraActivity(int id, [FromBody] UpdateCameraActivityDataModel data) { return(Json(CameraInfoHelper.UpdateCameraActivity(id, data.IsActive))); }