Exemplo n.º 1
0
        public void XmlRelationsTest()
        {
            var parentSchema = new TableSchema("XmlRelationsTest - Parent");

            parentSchema.Columns.AddValueColumn("ABC", typeof(string), "DEF");

            var childSchema = new TableSchema("XmlRelationsTest - Child 1");

            childSchema.Columns.AddValueColumn("Col1", typeof(uint), 35u);

            childSchema.Columns.AddForeignKey("Parent1", parentSchema, "Child1");
            childSchema.Columns.AddForeignKey("Parent2", parentSchema, "Child2");

            var pLogsSchema = new TableSchema("XmlRelationsTest - Parent Logs");

            pLogsSchema.Columns.AddForeignKey("Row", parentSchema, "History");
            pLogsSchema.Columns.AddValueColumn("Timestamp", typeof(DateTime), null);
            pLogsSchema.Columns.AddValueColumn("ABC", typeof(string), "DEF");

            var cLogsSchema = new TableSchema("XmlRelationsTest - Child Logs");

            cLogsSchema.Columns.AddForeignKey("Row", childSchema, "History");
            cLogsSchema.Columns.AddValueColumn("Timestamp", typeof(DateTime), null);
            cLogsSchema.Columns.AddValueColumn("Col1", typeof(uint), 35u);


            var newSchemas = TableSchema.FromXml(parentSchema.ToXml(), childSchema.ToXml(), pLogsSchema.ToXml(), cLogsSchema.ToXml());

            Func <TableSchema, TableSchema> NewSchema = oldSchema => newSchemas.Single(ts => ts.Name == oldSchema.Name);

            AssertSchemasEqual(parentSchema, NewSchema(parentSchema));
            AssertSchemasEqual(childSchema, NewSchema(childSchema));
            AssertSchemasEqual(pLogsSchema, NewSchema(pLogsSchema));
            AssertSchemasEqual(cLogsSchema, NewSchema(cLogsSchema));
        }
Exemplo n.º 2
0
        public void XmlEmptyTest()
        {
            var schema = new TableSchema("XmlEmptyTest");

            Assert.AreEqual(new XElement("TableSchema", new XAttribute("Name", "XmlEmptyTest")).ToString(), schema.ToXml().ToString());
            var newSchema = TableSchema.FromXml(schema.ToXml());

            AssertSchemasEqual(schema, newSchema);
        }
Exemplo n.º 3
0
        public void XmlSimpleTest()
        {
            var schema = new TableSchema("XmlSimpleTest");

            schema.Columns.AddValueColumn("Col1", typeof(DateTimeOffset?), null).Unique = true;
            schema.Columns.AddValueColumn("Col2", typeof(int?), 57);
            schema.Columns.AddValueColumn("Col3", typeof(int), null);
            schema.Columns.AddValueColumn("Col4", typeof(string), null);
            schema.Columns.AddValueColumn("Col5", typeof(string), "ABC").AllowNulls      = false;
            schema.Columns.AddValueColumn("Col6", typeof(double), Math.PI).Unique        = true;
            schema.Columns.AddValueColumn("Col7", typeof(DateTime), DateTime.Now).Unique = true;
            schema.PrimaryKey = schema.Columns.AddValueColumn("Col8", typeof(byte?), (byte)7);


            var newSchema = TableSchema.FromXml(schema.ToXml());

            AssertSchemasEqual(schema, newSchema);
        }