public async Task GetAdviserDetailByIdHttpTrigger_ReturnsStatusCodeNoContent_WhenAdviserDetailDoesNotExist() { _getAdviserDetailByIdHttpTriggerService.GetAdviserDetailByIdAsync(Arg.Any <Guid>()).Returns(Task.FromResult <Models.AdviserDetail>(null).Result); // Act var result = await RunFunction(ValidAdviserDetailId); // Assert Assert.IsInstanceOf <HttpResponseMessage>(result); Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode); }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "AdviserDetails/{adviserDetailId}")] HttpRequestMessage req, ILogger log, string adviserDetailId, [Inject] IHttpRequestMessageHelper httpRequestMessageHelper, [Inject] IGetAdviserDetailByIdHttpTriggerService getAdviserDetailByIdService) { var touchpointId = httpRequestMessageHelper.GetTouchpointId(req); if (string.IsNullOrEmpty(touchpointId)) { log.LogInformation("Unable to locate 'APIM-TouchpointId' in request header."); return(HttpResponseMessageHelper.BadRequest()); } log.LogInformation("Get Adviser Detail By Id C# HTTP trigger function processed a request. " + touchpointId); if (!Guid.TryParse(adviserDetailId, out var adviserDetailGuid)) { return(HttpResponseMessageHelper.BadRequest(adviserDetailGuid)); } var adviserDetail = await getAdviserDetailByIdService.GetAdviserDetailByIdAsync(adviserDetailGuid); return(adviserDetail == null ? HttpResponseMessageHelper.NoContent(adviserDetailGuid) : HttpResponseMessageHelper.Ok(JsonHelper.SerializeObject(adviserDetail))); }