Net core application. I have below controller method
public async Task<ActionResult> UpdateMapFile(int mapId, MapFileDetailsBusinessModel mapFileUploadActionsEntity)
{
var result = await _geoClient.SendRequestMapFileUpload<string, UpdateMapFileRequestModel>(
new UpdateMapFileRequestModel
{
MapFile = mapFileUploadActionsEntity,
MapId = mapId
}, "updatemapfile", HttpMethod.Put).ConfigureAwait(false);
return Ok(result);
}
This will return ActionResult type. The signature for SendRequestMapFileUpload as follows
Task<ActionResult> SendRequestMapFileUpload<T,U>(U request, string methodName, HttpMethod reqtype);
This will return Task<ActionResult>
. Below is my unit test case
Below is implementation of geo client
public async Task<ActionResult> SendRequestMapFileUpload<T,U>(U request, string methodName, HttpMethod reqtype)
{
return await SendRequest<T,U>(request, "/api/MapFileUpload/" + methodName, reqtype, _token);
}
Below is test case
[Test]
public async Task UpdateMapFile_ExpectedBehavior()
{
_mapFileUploadController.BuildMockControllerContext();
_geoClient.Setup(x => x.SendRequestMapFileUpload<string, UpdateMapFileRequestModel>(updateMapFileRequestModel, It.IsAny<string>(), HttpMethod.Put))
.Returns(//here how to return ActionResult);
var result = await _mapFileUploadController.UpdateMapFile(mapId, mapFileDetailsBusinessModel);
var statusCode = result as NoContentResult;
Assert.AreEqual(204, statusCode.StatusCode);
}
In the above method When I am mocking I have to return ActionResult. Here I am struggling what exactly and how to return ActionResult. can someone help me regarding this. Any help would be appreciated. Thank you