Example #1
0
        public void ParseSigleLineAsObject()
        {
            var parser = new DynamicObjectParser();
            var ssv    = SsvFactory.Create3ColumnsNDataLines(1);

            dynamic dynObj = parser.Parse(ssv).First();

            Assert.AreEqual("a1", dynObj.A);
            Assert.AreEqual("b1", dynObj.B);
            Assert.AreEqual("c1", dynObj.C);
        }
Example #2
0
        public void Parse3LineAsObjects()
        {
            var parser = new DynamicObjectParser();
            var ssv    = SsvFactory.Create3ColumnsNDataLines(3, "T");

            var dynObjects = parser.Parse(ssv).ToArray();

            Assert.AreEqual(3, dynObjects.Count());
            dynamic dynObj3 = dynObjects[2];

            Assert.AreEqual("a3", dynObj3.A);
            Assert.AreEqual("b3", dynObj3.B);
            Assert.AreEqual("c3", dynObj3.C);
        }
        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]);
        }
        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]);
        }