Beispiel #1
0
        public void SaveLoadXmlOptionsString()
        {
            var cbOrig = new DelimitedClassBuilder("Customers", ",");

            cbOrig.AddField("Field1", typeof(DateTime));
            cbOrig.AddField("FieldTwo", typeof(string));

            cbOrig.RecordCondition.Condition = RecordCondition.ExcludeIfMatchRegex;
            cbOrig.RecordCondition.Selector  = @"\w*";

            cbOrig.IgnoreCommentedLines.CommentMarker = "//";
            cbOrig.IgnoreCommentedLines.InAnyPlace    = false;

            cbOrig.IgnoreEmptyLines = true;
            cbOrig.IgnoreFirstLines = 123;
            cbOrig.IgnoreLastLines  = 456;

            cbOrig.SealedClass = false;
            string xml = cbOrig.SaveToXmlString();

            cbOrig = null;

            ClassBuilder cb2 = ClassBuilder.LoadFromXmlString(xml);

            Assert.AreEqual("Customers", cb2.ClassName);
            Assert.AreEqual(2, cb2.FieldCount);
            Assert.AreEqual("Field1", cb2.Fields[0].FieldName);

            Assert.AreEqual(RecordCondition.ExcludeIfMatchRegex, cb2.RecordCondition.Condition);
            Assert.AreEqual(@"\w*", cb2.RecordCondition.Selector);

            Assert.AreEqual("//", cb2.IgnoreCommentedLines.CommentMarker);
            Assert.AreEqual(false, cb2.IgnoreCommentedLines.InAnyPlace);
            Assert.AreEqual(false, cb2.SealedClass);

            Assert.AreEqual(true, cb2.IgnoreEmptyLines);
            Assert.AreEqual(123, cb2.IgnoreFirstLines);
            Assert.AreEqual(456, cb2.IgnoreLastLines);
        }