public async Task UpdateMissingPlateRecord_WhenCalled_ShouldCallHelper() { //Arrange var expectedPlateNumber = "BAA254"; var expectedSearchDateTime = new DateTime(2018, 05, 17); var expectedDataModel = new PostPlateRecordDataModel() { PlateNumber = expectedPlateNumber, SearchStartDateTime = expectedSearchDateTime, }; var fakeMissingPlateHelper = A.Fake <IMissingPlateHelper>(); var expectedId = 5; var expectedMissingPlateInfo = new MissingLicensePlate() { Id = expectedId }; A.CallTo(() => fakeMissingPlateHelper.UpdatePlateRecord(expectedId, expectedPlateNumber, expectedSearchDateTime)) .Returns(expectedMissingPlateInfo); var mlpController = new MissingPlateController() { MissingPlateHelper = fakeMissingPlateHelper, Request = new HttpRequestMessage() }; //Act var result = mlpController.UpdatePlateRecordById(expectedId, expectedDataModel); //Assert A.CallTo(() => fakeMissingPlateHelper.UpdatePlateRecord(expectedId, expectedPlateNumber, expectedSearchDateTime)) .MustHaveHappenedOnceExactly(); var httpResponse = await result.ExecuteAsync(new CancellationToken()); var jsonContent = await httpResponse.Content.ReadAsStringAsync(); var expectedJson = JsonConvert.SerializeObject(expectedMissingPlateInfo); jsonContent.ShouldBe(expectedJson); }
public IHttpActionResult UpdatePlateRecordById(int id, [FromBody] PostPlateRecordDataModel data) { return(Json(MissingPlateHelper.UpdatePlateRecord(id, data.PlateNumber, data.SearchStartDateTime))); }
public IHttpActionResult InsertMissingPlateByNumber([FromBody] PostPlateRecordDataModel data) { return(Json(MissingPlateHelper.InsertPlateRecord(data.PlateNumber, data.SearchStartDateTime))); }