Example #1
0
        public void Parse_SetOfValidValueStrings_ParsedCorrectly()
        {
            CheckValidParse(" bytes 1-2/3 ", new ContentRangeHeaderValue(1, 2, 3));
            CheckValidParse("bytes  *  /  3", new ContentRangeHeaderValue(3));

            CheckValidParse(" custom 1234567890123456789-1234567890123456799/*",
                            new ContentRangeHeaderValue(1234567890123456789, 1234567890123456799)
            {
                Unit = "custom"
            });

            CheckValidParse(" custom * / 123 ",
                            new ContentRangeHeaderValue(123)
            {
                Unit = "custom"
            });

            // Note that we don't have a public constructor for value 'bytes */*' since the RFC doesn't mention a
            // scenario for it. However, if a server returns this value, we're flexible and accept it.
            var result = ContentRangeHeaderValue.Parse("bytes */*");

            Assert.Equal("bytes", result.Unit);
            Assert.Null(result.From);
            Assert.Null(result.To);
            Assert.Null(result.Length);
            Assert.False(result.HasRange, "HasRange");
            Assert.False(result.HasLength, "HasLength");
        }
Example #2
0
        private void CheckValidParse(string?input, ContentRangeHeaderValue expectedResult)
        {
            var result = ContentRangeHeaderValue.Parse(input);

            Assert.Equal(expectedResult, result);
        }
Example #3
0
 public void Parse_SetOfInvalidValueStrings_Throws(string?input)
 {
     Assert.Throws <FormatException>(() => ContentRangeHeaderValue.Parse(input));
 }