System.Net.Http.Tests.HttpContentHeadersTest.ContentLanguage_ReadAndWriteProperty_ValueMatchesPriorSetValue C# (CSharp) Method

ContentLanguage_ReadAndWriteProperty_ValueMatchesPriorSetValue() private method

        public void ContentLanguage_ReadAndWriteProperty_ValueMatchesPriorSetValue()
        {
            Assert.Equal(0, _headers.ContentLanguage.Count);

            // Note that Content-Language for us is just a list of tokens. We don't verify if the format is a valid
            // language tag. Users will pass the language tag to other classes like Encoding.GetEncoding() to retrieve
            // an encoding. These classes will do not only syntax checking but also verify if the language tag exists.
            _headers.ContentLanguage.Add("custom1");
            _headers.ContentLanguage.Add("custom2");

            Assert.Equal(2, _headers.ContentLanguage.Count);
            Assert.Equal(2, _headers.GetValues("Content-Language").Count());

            Assert.Equal("custom1", _headers.ContentLanguage.ElementAt(0));
            Assert.Equal("custom2", _headers.ContentLanguage.ElementAt(1));

            _headers.ContentLanguage.Clear();
            Assert.Equal(0, _headers.ContentLanguage.Count);
            Assert.False(_headers.Contains("Content-Language"));
        }
HttpContentHeadersTest