public async Task MarkFoundMissingPlate_WhenCalled_ShouldCallHelper() { var fakeMissingPlateHelper = A.Fake <IMissingPlateHelper>(); var expectedId = 5; var requestedDateTime = new DateTime(2018, 05, 15); var expectedSearch = LicensePlateFoundStatus.Found; var expectedDataModel = new MarkFoundRecordDataModel() { EndDateTime = new DateTime(2018, 05, 15), Status = LicensePlateFoundStatus.Found, }; var expectedMissingPlateInfo = new MissingLicensePlate() { Id = expectedId }; A.CallTo(() => fakeMissingPlateHelper.MarkFoundPlate(expectedId, requestedDateTime, expectedSearch)) .Returns(expectedMissingPlateInfo); var mlpController = new MissingPlateController() { MissingPlateHelper = fakeMissingPlateHelper, Request = new HttpRequestMessage() }; //Act var result = mlpController.MarkFoundMissingPlate(expectedId, expectedDataModel); //Assert A.CallTo(() => fakeMissingPlateHelper.MarkFoundPlate(expectedId, requestedDateTime, expectedSearch)) .MustHaveHappenedOnceExactly(); var httpResponse = await result.ExecuteAsync(new CancellationToken()); var jsonContent = await httpResponse.Content.ReadAsStringAsync(); var expectedJson = JsonConvert.SerializeObject(expectedMissingPlateInfo); jsonContent.ShouldBe(expectedJson); }
public IHttpActionResult MarkFoundMissingPlate(int plateId, [FromBody] MarkFoundRecordDataModel data) { return(Json(MissingPlateHelper.MarkFoundPlate(plateId, data.EndDateTime, data.Status))); }