Пример #1
0
        private void CheckInvalidTryParse(string input)
        {
            RangeHeaderValue result = null;

            Assert.False(RangeHeaderValue.TryParse(input, out result));
            Assert.Null(result);
        }
Пример #2
0
        private void CheckValidTryParse(string input, RangeHeaderValue expectedResult)
        {
            RangeHeaderValue result = null;

            Assert.True(RangeHeaderValue.TryParse(input, out result));
            Assert.Equal(expectedResult, result);
        }
        private static void CheckValidTryParse(string input, long?expectedFrom, long?expectedTo)
        {
            RangeHeaderValue result;

            Assert.True(RangeHeaderValue.TryParse("byte=" + input, out result), input);

            var ranges = result.Ranges.ToArray();

            Assert.Single(ranges);

            var range = ranges.First();

            Assert.Equal(expectedFrom, range.From);
            Assert.Equal(expectedTo, range.To);
        }
        private static void CheckValidTryParse(string input, params Tuple <long?, long?>[] expectedRanges)
        {
            RangeHeaderValue result;

            Assert.True(RangeHeaderValue.TryParse("byte=" + input, out result), input);

            var ranges = result.Ranges.ToArray();

            Assert.Equal(expectedRanges.Length, ranges.Length);

            for (int i = 0; i < expectedRanges.Length; i++)
            {
                Assert.Equal(expectedRanges[i].Item1, ranges[i].From);
                Assert.Equal(expectedRanges[i].Item2, ranges[i].To);
            }
        }
        [InlineData("-9999999999999999999")]     // 19-digit numbers outside the Int64 range.
        public void TryParse_DifferentInvalidScenarios_AllReturnFalse(string input)
        {
            RangeHeaderValue result;

            Assert.False(RangeHeaderValue.TryParse("byte=" + input, out result));
        }