Пример #1
0
        public void AddEntityId_DoesNotAddEntityId_IfResponseStatusCodeIsOtherThanNoContent()
        {
            // Arrange
            var response = ResponseFactory.Create(StatusCodes.Status200OK);

            // Act
            ResultHelpers.AddEntityId(response, () => _entityId);

            // Assert
            Assert.False(response.Headers.ContainsKey(ResultHelpers.EntityIdHeaderName));
        }
Пример #2
0
        public void AddEntityId_AddsEntityId_IfResponseStatusCodeIsNoContent()
        {
            // Arrange
            var response = ResponseFactory.Create(StatusCodes.Status204NoContent);

            // Act
            ResultHelpers.AddEntityId(response, () => _entityId);

            // Assert
            var entityIdHeaderValues = response.Headers[ResultHelpers.EntityIdHeaderName].ToList();

            Assert.Single(entityIdHeaderValues);
            Assert.Equal(_entityId.ToString(), entityIdHeaderValues.Single());
        }
Пример #3
0
        public void AddEntityId_DoesNotAddEntityId_IfResponseStatusCodeIsOtherThanNoContent()
        {
            // Arrange
            var response = ResponseFactory.Create(HttpStatusCode.OK);

            // Act
            ResultHelpers.AddEntityId(response, () => _entityId);

            // Assert
#if NETCORE
            Assert.False(response.Headers.ContainsKey(ResultHelpers.EntityIdHeaderName));
#else
            Assert.False(response.Headers.Contains(ResultHelpers.EntityIdHeaderName));
#endif
        }
Пример #4
0
        public void AddEntityId_AddsEntityId_IfResponseStatusCodeIsNoContent()
        {
            // Arrange
            var response = ResponseFactory.Create(HttpStatusCode.NoContent);

            // Act
            ResultHelpers.AddEntityId(response, () => _entityId);

            // Assert
#if NETCORE
            var entityIdHeaderValues = response.Headers[ResultHelpers.EntityIdHeaderName].ToList();
#else
            var entityIdHeaderValues = response.Headers.GetValues(ResultHelpers.EntityIdHeaderName).ToList();
#endif
            Assert.Single(entityIdHeaderValues);
            Assert.Equal(_entityId.ToString(), entityIdHeaderValues.Single());
        }