Exemple #1
0
        public void GivenNullParameters_WhenTryAddErroneousAttributesHeader_ThenThrowsArgumentNullException()
        {
            var context = new DefaultHttpContext();

            Assert.Throws <ArgumentNullException>(() => HttpResponseExtensions.TryAddErroneousAttributesHeader(null, Array.Empty <string>()));
            Assert.Throws <ArgumentNullException>(() => HttpResponseExtensions.TryAddErroneousAttributesHeader(context.Response, null));
        }
Exemple #2
0
        public void GivenNonEmptyErroneousTags_WhenTryAddErroneousAttributesHeader_ThenShouldAddExpectedHeader()
        {
            var context = new DefaultHttpContext();
            var tags    = new string[] { "PatientAge", "00011231" };

            Assert.True(HttpResponseExtensions.TryAddErroneousAttributesHeader(context.Response, tags));

            Assert.True(context.Response.Headers.TryGetValue(HttpResponseExtensions.ErroneousAttributesHeader, out StringValues headerValue));
            Assert.Single(headerValue);
            Assert.Equal(string.Join(",", tags), headerValue[0]); // Should continue to be escaped!
        }
Exemple #3
0
        public void GivenEmptyErroneousTags_WhenTryAddErroneousAttributesHeader_ThenShouldReturnFalse()
        {
            var context = new DefaultHttpContext();

            Assert.False(HttpResponseExtensions.TryAddErroneousAttributesHeader(context.Response, Array.Empty <string>()));
        }