Пример #1
0
        public void FormatSsvByCustomNotation()
        {
            var ssv = new Ssv();

            ssv.InsertTableNameLine("T");
            ssv.InsertHeaderColumnsLine("A", "B", "C");
            ssv.InsertDataLine("A1", "B1", "C1");
            ssv.InsertDataLine("A2", "B2", "C2");

            var notation = new Notation()
            {
                ValueDelimiter  = " || ",
                TableStartMark  = "<<",
                TableEndMak     = ">>",
                HeaderStartMark = "{{",
                HeaderEndMark   = "}}"
            };

            var formatter = new SsvFormatter()
            {
                SsvNotation = notation
            };
            var format = formatter.Format(ssv);

            var lines = format.Split(new[] { formatter.SsvNotation.LineDelimiter }, StringSplitOptions.None).ToArray();

            Assert.AreEqual(4, lines.Length);
            Assert.AreEqual("<<T>>", lines[0]);
            Assert.AreEqual("{{A || B || C}}", lines[1]);
            Assert.AreEqual("A1 || B1 || C1", lines[2]);
        }
Пример #2
0
        public void FormatSsvByDefaultNotation()
        {
            var ssv = SsvFactory.Create3ColumnsNDataLines(2, "T");

            var formatter = new SsvFormatter();
            var format    = formatter.Format(ssv);

            var lines = format.Split(new[] { formatter.SsvNotation.LineDelimiter }, StringSplitOptions.None).ToArray();

            Assert.AreEqual(4, lines.Length);
            Assert.AreEqual("[[[T]]]", lines[0]);
            Assert.AreEqual("[[A;B;C]]", lines[1]);
            Assert.AreEqual("a1;b1;c1", lines[2]);
        }
Пример #3
0
        public void FormatSsvByCustomNotation()
        {
            var ssv      = SsvFactory.Create3ColumnsNDataLines(2, "T");
            var notation = SsvFactory.CreateCustomNotation();

            var formatter = new SsvFormatter()
            {
                SsvNotation = notation
            };
            var format = formatter.Format(ssv);

            var lines = format.Split(new[] { formatter.SsvNotation.LineDelimiter }, StringSplitOptions.None).ToArray();

            Assert.AreEqual(4, lines.Length);
            Assert.AreEqual("<<T>>", lines[0]);
            Assert.AreEqual("{{A || B || C}}", lines[1]);
            Assert.AreEqual("a1 || b1 || c1", lines[2]);
        }
Пример #4
0
        public void FormatSsvByDefaultNotation()
        {
            var ssv = new Ssv();

            ssv.InsertTableNameLine("T");
            ssv.InsertHeaderColumnsLine("A", "B", "C");
            ssv.InsertDataLine("A1", "B1", "C1");
            ssv.InsertDataLine("A2", "B2", "C2");

            var formatter = new SsvFormatter();
            var format    = formatter.Format(ssv);

            var lines = format.Split(new[] { formatter.SsvNotation.LineDelimiter }, StringSplitOptions.None).ToArray();

            Assert.AreEqual(4, lines.Length);
            Assert.AreEqual("[[[T]]]", lines[0]);
            Assert.AreEqual("[[A;B;C]]", lines[1]);
            Assert.AreEqual("A1;B1;C1", lines[2]);
        }