public void GetETagFromVersion_ConvertsETag(string version)
        {
            // Arrange
            byte[] versionData = Encoding.UTF8.GetBytes(version);
            string etag        = "\"" + Convert.ToBase64String(versionData) + "\"";

            // Act
            EntityTagHeaderValue actualETag = TableQueryFilter.GetETagFromVersion(versionData);

            // Assert
            Assert.Equal(etag, actualETag.Tag);
        }
        public void AddETagResponseHeader_FindsETag(HttpContent content, string expected)
        {
            // Arrange
            EntityTagHeaderValue expectedETag = expected != null?EntityTagHeaderValue.Parse(expected) : null;

            HttpResponseMessage response = new HttpResponseMessage()
            {
                Content = content
            };

            // Act
            TableQueryFilter.AddETagResponseHeader(response);
            EntityTagHeaderValue etag = response.Headers.ETag;

            // Assert
            Assert.Equal(expectedETag, etag);
        }
        public void GetElementType_DetectsResponseTypeAttribute(Type returnType, Type responseType, Type expected)
        {
            // Arrange
            ResponseTypeAttribute       responseTypeAttribute = new ResponseTypeAttribute(responseType);
            Mock <HttpActionDescriptor> descriptorMock        = new Mock <HttpActionDescriptor> {
                CallBase = true
            };

            descriptorMock.Setup <Type>(d => d.ReturnType)
            .Returns(returnType)
            .Verifiable();
            descriptorMock.Setup <Collection <ResponseTypeAttribute> >(d => d.GetCustomAttributes <ResponseTypeAttribute>(true))
            .Returns(new Collection <ResponseTypeAttribute> {
                responseTypeAttribute
            })
            .Verifiable();

            // Act
            Type actual = TableQueryFilter.GetElementType(descriptorMock.Object);

            // Assert
            Assert.Equal(expected, actual);
        }