/// <inheritdoc/> public virtual async Task <HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken) { IHttpActionResult result = GetInnerActionResult(); HttpResponseMessage response = await result.ExecuteAsync(cancellationToken); response.Headers.Location = LocationHeader; ResultHelpers.AddEntityId(response, () => EntityId); return(response); }
public void AddEntityId_DoesNotAddEntityId_IfResponseStatusCodeIsOtherThanNoContent() { // Arrange var response = new HttpResponseMessage(HttpStatusCode.OK); // Act ResultHelpers.AddEntityId(response, () => _entityId); // Assert Assert.False(response.Headers.Contains(ResultHelpers.EntityIdHeaderName)); }
public void AddEntityId_AddsEntityId_IfResponseStatusCodeIsNoContent() { // Arrange var response = new HttpResponseMessage(HttpStatusCode.NoContent); // Act ResultHelpers.AddEntityId(response, () => _entityId); // Assert var entityIdHeaderValues = response.Headers.GetValues(ResultHelpers.EntityIdHeaderName).ToList(); Assert.Single(entityIdHeaderValues); Assert.Equal(_entityId.ToString(), entityIdHeaderValues.Single()); }