/// <summary>
        /// Ensures that the response has the required headers for conditional HTTP usage.
        /// </summary>
        /// <param name="expected">The <see cref="ITableData"/> representing the entity returned.</param>
        /// <param name="response">The response to check.</param>
        public static void ResponseHasConditionalHeaders(ITableData expected, HttpResponseMessage response)
        {
            var lastModified = expected.UpdatedAt.ToString(DateTimeFormatInfo.InvariantInfo.RFC1123Pattern, CultureInfo.InvariantCulture);

            HasHeader(response, HeaderNames.ETag, expected.GetETag());
            HasHeader(response, HeaderNames.LastModified, lastModified);
        }
        public void GetETag_Null_WhenNullEntity()
        {
            // Arrange
            ITableData entity = null;

            // Act
            string actual = entity.GetETag();

            // Assert
            Assert.Null(actual);
        }
Exemple #3
0
 /// <summary>
 /// Adds the appropriate headers to the provided header dictionary, based on the
 /// system properties within the entity.
 /// </summary>
 /// <param name="headers">The <see cref="IHeaderDictionary"/> to adjust.</param>
 /// <param name="entity">The entity to use as source for the headers.</param>
 internal static void AddFromEntity(this IHeaderDictionary headers, ITableData entity)
 {
     if (entity != null)
     {
         if (entity.HasValidVersion())
         {
             headers.Remove(HeaderNames.ETag);
             headers.Add(HeaderNames.ETag, entity.GetETag());
         }
         if (entity.UpdatedAt != default)
         {
             headers.Remove(HeaderNames.LastModified);
             headers.Add(HeaderNames.LastModified, entity.UpdatedAt.ToString(DateTimeFormatInfo.InvariantInfo.RFC1123Pattern, CultureInfo.InvariantCulture));
         }
     }
 }