public void Parse_NullValue_Throw()
        {
            Int64NumberHeaderParser parser = Int64NumberHeaderParser.Parser;
            int index = 0;

            Assert.Throws <FormatException>(() => { parser.ParseValue(null, null, ref index); });
        }
        public void ToString_UseDifferentValues_MatchExpectation()
        {
            Int64NumberHeaderParser parser = Int64NumberHeaderParser.Parser;

            Assert.Equal("123456789012345", parser.ToString((long)123456789012345));
            Assert.Equal("0", parser.ToString((long)0));
        }
        public void Properties_ReadValues_MatchExpectation()
        {
            Int64NumberHeaderParser parser = Int64NumberHeaderParser.Parser;

            Assert.False(parser.SupportsMultipleValues, "SupportsMultipleValues");
            Assert.Null(parser.Comparer);
        }
        public void Parse_InvalidValue_Throw()
        {
            // This test verifies that Parse() correctly calls TryParse().
            Int64NumberHeaderParser parser = Int64NumberHeaderParser.Parser;
            int index = 0;

            Assert.Throws <FormatException>(() => { parser.ParseValue("a", null, ref index); });
        }
        private void CheckValidParsedValue(string input, int startIndex, long expectedResult, int expectedIndex)
        {
            Int64NumberHeaderParser parser = Int64NumberHeaderParser.Parser;
            object result = 0;

            Assert.True(parser.TryParseValue(input, null, ref startIndex, out result),
                        string.Format("TryParse returned false: {0}", input));
            Assert.Equal(expectedResult, result);
            Assert.Equal(expectedIndex, startIndex);
        }
        private void CheckInvalidParsedValue(string input, int startIndex)
        {
            Int64NumberHeaderParser parser = Int64NumberHeaderParser.Parser;
            object result   = 0;
            int    newIndex = startIndex;

            Assert.False(parser.TryParseValue(input, null, ref newIndex, out result),
                         string.Format("TryParse returned true: {0}", input));
            Assert.Equal(null, result);
            Assert.Equal(startIndex, newIndex);
        }
        public void Parse_ValidValue_ReturnsLongValue()
        {
            // This test verifies that Parse() correctly calls TryParse().
            Int64NumberHeaderParser parser = Int64NumberHeaderParser.Parser;
            int index = 2;

            Assert.Equal((long)15, parser.ParseValue("  15", null, ref index));
            Assert.Equal(4, index);

            index = 0;
            Assert.Equal((long)15, parser.ParseValue("  15", null, ref index));
            Assert.Equal(4, index);
        }