Exemple #1
0
        public void FieldWithMultiLineDescriptionWithQuotes()
        {
            var lines = new[]
            {
                "ADD TABLE \"TheTable\"",
                "  AREA \"tableArea\"",
                "  DESCRIPTION \"The description of the table\"",
                "  DUMP-NAME \"thetable\"",
                string.Empty,
                "ADD FIELD \"TheField\" OF \"TheTable\" AS character ",
                "  DESCRIPTION \"First line of field description",
                "Second line of \"\"field\"\" description\"",
                "  FORMAT \"x(8)\"",
                "  INITIAL \"\"",
                "  POSITION 8",
                "  MAX-WIDTH 16",
                "  ORDER 80",
                "  MANDATORY"
            };

            var result = new ParseDefinitions()
                         .Parse(lines)
                         .ToArray();

            var expectedDescription = string.Join("\r\n", "First line of field description", "Second line of \"field\" description");

            Assert.That(result.Single().Fields.Single().Description, Is.EqualTo(expectedDescription));
        }
Exemple #2
0
        private static void Run(string[] definitionLines, string output)
        {
            var tables = new ParseDefinitions().Parse(definitionLines);
            var sql    = string.Join("\r\n\r\n", tables.Select(x => x.ToSql()));
            var fk     = ForeignKeyService.SuggestForeignKeys(tables);

            File.WriteAllText(output, sql, Encoding.UTF8);
            File.AppendAllLines(output, new[] { "\r\n-- Foreign keys --\r\n" }, Encoding.UTF8);
            File.AppendAllLines(output, fk, Encoding.UTF8);
        }