public void StrictTextDelimiterPositioningEnabledSpacesEnabledWithTrailingSpacesMultiCharTextDelimiterMultiCharSeperator()
        {
            var opts = new ExplodeOptions(new Delimiters("_x_", "xx"));

            opts.StrictTextDelimiterPositioning = true;
            opts.StrictTextDelimiterPositioningAllowLeadingTrailingSpaces = true;

            var text = @"one_x_    xxtwoxx  _x_three";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.True(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("two", sl[1]);
            Assert.Equal("three", sl[2]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("    xxtwoxx  ", sl[1]);
            Assert.Equal("three", sl[2]);
        }
        public void StrictTextDelimiterPositioningEnabledSpacesEnabledWithLeadingSpaces()
        {
            var opts = new ExplodeOptions(new Delimiters());

            opts.StrictTextDelimiterPositioning = true;
            opts.StrictTextDelimiterPositioningAllowLeadingTrailingSpaces = true;

            var text = @"one,    ""two"",three";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.True(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("two", sl[1]);
            Assert.Equal("three", sl[2]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("    \"two\"", sl[1]);
            Assert.Equal("three", sl[2]);
        }
        public void StrictTextDelimiterEnabledQuotesWithinCell()
        {
            var opts = new ExplodeOptions(new Delimiters());

            opts.StrictTextDelimiterPositioning = true;

            var text = @"one,t""wo"",three";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.False(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("t\"wo\"", sl[1]);
            Assert.Equal("three", sl[2]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("t\"wo\"", sl[1]);
            Assert.Equal("three", sl[2]);
        }
        public void StringTextDelimiterDisabledQuotesWithinCellMultiCharTextDelimiter()
        {
            var opts = new ExplodeOptions(new Delimiters(',', "xx"));

            opts.StrictTextDelimiterPositioning = false;

            var text = @"one,txxwoxx,three";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.True(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("two", sl[1]);
            Assert.Equal("three", sl[2]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("txxwoxx", sl[1]);
            Assert.Equal("three", sl[2]);
        }
        public void InsideDoubleTextDelimitersEnablesStrictPositioningDisabledAsLastField()
        {
            var opts = new ExplodeOptions(new Delimiters());

            opts.AllowInsideDoubleTextDelimiters = true;
            opts.StrictTextDelimiterPositioning  = true;

            var text = @"one,""t""""wo""";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.True(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(2, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("t\"wo", sl[1]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(2, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("\"t\"\"wo\"", sl[1]);
        }
        public void StrictTextDelimiterDisabledStandardQuotedCell()
        {
            var opts = new ExplodeOptions(new Delimiters());

            opts.StrictTextDelimiterPositioning = false;

            var text = @"one,""two"",three";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.True(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("two", sl[1]);
            Assert.Equal("three", sl[2]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("\"two\"", sl[1]);
            Assert.Equal("three", sl[2]);
        }
        public void InsideDoubleTextDelimitersDisabledStrictPositioningDisabled()
        {
            var opts = new ExplodeOptions(new Delimiters());

            opts.AllowInsideDoubleTextDelimiters = false;
            opts.StrictTextDelimiterPositioning  = false;

            var text = @"one,""t""""wo"",three";

            //  "       in string
            //  t       take t
            //  "       out string
            //  "       in string
            //  w       take w
            //  o       take o
            //  "       out string

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.True(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal(@"two", sl[1]);
            Assert.Equal("three", sl[2]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("\"t\"\"wo\"", sl[1]);
            Assert.Equal("three", sl[2]);
        }
        public void CharacterJustSeparators()
        {
            var opts = new ExplodeOptions(new Delimiters());
            var text = ",,,";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.False(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(4, sl.Count);
            Assert.Equal("", sl[0]);
            Assert.Equal("", sl[1]);
            Assert.Equal("", sl[2]);
            Assert.Equal("", sl[3]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(4, sl.Count);
            Assert.Equal("", sl[0]);
            Assert.Equal("", sl[1]);
            Assert.Equal("", sl[2]);
            Assert.Equal("", sl[3]);
        }
        public void CharacterEmptyFieldAtEnd()
        {
            var opts = new ExplodeOptions(new Delimiters());
            var text = "one,two,three,";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.False(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(4, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("two", sl[1]);
            Assert.Equal("three", sl[2]);
            Assert.Equal("", sl[3]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(4, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("two", sl[1]);
            Assert.Equal("three", sl[2]);
            Assert.Equal("", sl[3]);
        }
        public void TextDelimiterDisabledWithInsideSeparator()
        {
            var opts = new ExplodeOptions(new Delimiters());

            opts.EnableTextDelimiter = false;

            var text = @"one,""t,wo"",three";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.False(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(4, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal(@"""t", sl[1]);
            Assert.Equal(@"wo""", sl[2]);
            Assert.Equal("three", sl[3]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(4, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal(@"""t", sl[1]);
            Assert.Equal(@"wo""", sl[2]);
            Assert.Equal("three", sl[3]);
        }
        private void TextToStringArrayTest()
        {
            var opts = new ExplodeOptions(new Delimiters());

            //defaults
            opts.StrictTextDelimiterPositioning = true;
            opts.StrictTextDelimiterPositioningAllowLeadingTrailingSpaces = true;

            var text = @"one,""two"",""three""";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.True(sr.WereAnyCellsTextDelimited);

            string[] sa = sr.Cells.ToStringArray();

            Assert.Equal(3, sa.Length);
            Assert.Equal("one", sa[0]);
            Assert.Equal("two", sa[1]);
            Assert.Equal("three", sa[2]);

            sa = sr.Cells.RawTextToStringArray();

            Assert.Equal(3, sa.Length);
            Assert.Equal("one", sa[0]);
            Assert.Equal("\"two\"", sa[1]);
            Assert.Equal("\"three\"", sa[2]);
        }
        private void TerminatedWithTextDelimitedFieldMultiCharTextDelimiterTrailingSpaces()
        {
            var opts = new ExplodeOptions(new Delimiters(',', "<>"));

            //defaults
            opts.StrictTextDelimiterPositioning = true;
            opts.StrictTextDelimiterPositioningAllowLeadingTrailingSpaces = true;

            var text = @"one,<>two<>,<>three<>   ";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.True(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("two", sl[1]);
            Assert.Equal("three", sl[2]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("<>two<>", sl[1]);
            Assert.Equal("<>three<>   ", sl[2]);
        }
        public void CharacterDifferentSeperator()
        {
            var opts = new ExplodeOptions(new Delimiters(':'));
            var text = "one:two:three";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.False(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("two", sl[1]);
            Assert.Equal("three", sl[2]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("two", sl[1]);
            Assert.Equal("three", sl[2]);
        }
        public void StringTextDelimitersWithEmbeddedTextDelimiterAndFieldSeparator()
        {
            var opts = new ExplodeOptions(new Delimiters(",", "_x_"));
            var text = @"one,_x_two_x__x_,q,uote_x_,three";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.True(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("two_x_,q,uote", sl[1]);
            Assert.Equal("three", sl[2]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("_x_two_x__x_,q,uote_x_", sl[1]);
            Assert.Equal("three", sl[2]);
        }
        public void StringTextDelimiters()
        {
            var opts = new ExplodeOptions(new Delimiters("_x_", "<>"));
            var text = "one_x_<>two<>_x_three";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.True(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("two", sl[1]);
            Assert.Equal("three", sl[2]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("<>two<>", sl[1]);
            Assert.Equal("three", sl[2]);
        }
        public void CharacterTextDelimitersWithEmbeddedTextDelimiter()
        {
            var opts = new ExplodeOptions(new Delimiters());
            var text = @"one,""two""""quote"",three";

            ExplodeResult sr = Explode.ExplodeString(text, opts);

            Assert.True(sr.WereAnyCellsTextDelimited);

            List <string> sl = sr.Cells.ToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal(@"two""quote", sl[1]);
            Assert.Equal("three", sl[2]);

            sl = sr.Cells.RawTextToStringList();

            Assert.Equal(3, sl.Count);
            Assert.Equal("one", sl[0]);
            Assert.Equal("\"two\"\"quote\"", sl[1]);
            Assert.Equal("three", sl[2]);
        }