public void AddServiceVersion_DoesNotAddServiceVersion_IfResponseStatusCodeIsOtherThanNoContent() { // Arrange var response = ResponseFactory.Create(StatusCodes.Status200OK); // Act ResultHelpers.AddServiceVersion(response, () => _version); // Assert Assert.False(response.Headers.ContainsKey(ODataVersionConstraint.ODataServiceVersionHeader)); }
public void AddServiceVersion_AddsODataVersion_IfResponseStatusCodeIsNoContent() { // Arrange var response = ResponseFactory.Create(StatusCodes.Status204NoContent); // Act ResultHelpers.AddServiceVersion(response, () => _version); // Assert var versionHeaderValues = response.Headers[ODataVersionConstraint.ODataServiceVersionHeader].ToList(); Assert.Single(versionHeaderValues); Assert.Equal(_version, versionHeaderValues.Single()); }
public void AddServiceVersion_AddsODataVersion_IfResponseStatusCodeIsNoContent() { // Arrange var response = ResponseFactory.Create(HttpStatusCode.NoContent); // Act ResultHelpers.AddServiceVersion(response, () => _version); // Assert #if NETCORE var versionHeaderValues = response.Headers[ODataVersionConstraint.ODataServiceVersionHeader].ToList(); #else var versionHeaderValues = response.Headers.GetValues(ODataVersionConstraint.ODataServiceVersionHeader).ToList(); #endif Assert.Single(versionHeaderValues); Assert.Equal(_version, versionHeaderValues.Single()); }