コード例 #1
0
        public void DelimitedParseStateDelimit_EmptyFields_DataNotAccumulated()
        {
            var testSubject = DelimitedParserStub.Create <DelimitedParserStateDelimit>(',');

            testSubject.Parse("abc,");

            Assert.Empty(testSubject.Fields);
        }
コード例 #2
0
        public void DelimitedParseStateQuote_MissingEndQuote_DoesNotComplete()
        {
            var testSubject = DelimitedParserStub.Create <DelimitedParserStateQuote>(',');

            testSubject.Parse("f\"\"oo");

            Assert.Empty(testSubject.Fields);
        }
コード例 #3
0
        public void DelimitedParserStateDelimit_InitialState_IsNotComplete()
        {
            var testSubject = DelimitedParserStub.Create <DelimitedParserStateDelimit>(',');

            testSubject.Parse(string.Empty);

            Assert.Empty(testSubject.Fields);
        }
コード例 #4
0
        public void DelimitedParseStateQuote_NewLine_ParseQuotedField()
        {
            var testSubject = DelimitedParserStub.Create <DelimitedParserStateQuote>(',');

            testSubject.Parse("f\r\noo\"");

            Assert.Equal(1, testSubject.Fields.Count);
            Assert.Equal("f\r\noo", testSubject.Fields[0]);
        }
コード例 #5
0
        public void DelimitedParseStateQuote_QuoteAndDelimiter_ParseQuotedField()
        {
            var testSubject = DelimitedParserStub.Create <DelimitedParserStateQuote>(',');

            testSubject.Parse("foo,\"\"\",");

            Assert.Equal(1, testSubject.Fields.Count);
            Assert.Equal("foo,\"", testSubject.Fields[0]);
        }
コード例 #6
0
        public void DelimitedParseStateQuote_EscapedNonQuoteCharacter_ParseQuotedField()
        {
            var testSubject = DelimitedParserStub.Create <DelimitedParserStateQuote>(',');

            testSubject.Parse("f\\roo\"");

            Assert.Equal(1, testSubject.Fields.Count);
            Assert.Equal("f\\roo", testSubject.Fields[0]);
        }
コード例 #7
0
        public void DelimitedParseStateCapture_LF_DoNotCapture()
        {
            var testSubject = DelimitedParserStub.Create <DelimitedParserStateCapture>(',');

            testSubject.Parse("foo\n");

            Assert.Equal(1, testSubject.Fields.Count);
            Assert.Equal("foo", testSubject.Fields[0]);
        }
コード例 #8
0
        public void DelimitedParseStateCapture_EmptyField()
        {
            var testSubject = DelimitedParserStub.Create <DelimitedParserStateCapture>(',');

            testSubject.Parse(",");

            Assert.Equal(1, testSubject.Fields.Count);
            Assert.Equal("", testSubject.Fields[0]);
        }
コード例 #9
0
        public static DelimitedParserStub Create <T>(char delimiter, params object[] args)
            where T : DelimitedParserStateContext
        {
            var parser          = new DelimitedParserStub(delimiter);
            var constructorArgs = Enumerable.Repeat <object>(parser, 1).Concat(args);

            parser.Context = (T)Activator.CreateInstance(typeof(T), constructorArgs.ToArray());

            return(parser);
        }
コード例 #10
0
        public void DelimitedParseStateQuote_InitialState_IsNotComplete()
        {
            var testSubject = DelimitedParserStub.Create <DelimitedParserStateQuote>(',');

            Assert.Empty(testSubject.Fields);
        }