Beispiel #1
0
 public void Setup()
 {
     DbInstallFactory.InitTestDatabase(DbName);
     dir   = FileSystemHelper.ResetTemporaryDirectory();
     file  = Path.Combine(dir, "a.sql");
     file2 = Path.Combine(dir, "b.sql");
 }
        public void Setup()
        {
            DbInstallFactory.InitTestDatabase(DbName);
            dir   = FileSystemHelper.ResetTemporaryDirectory();
            file  = Path.Combine(dir, "a.bxls");
            file2 = Path.Combine(dir, "b.bxls");
            file3 = Path.Combine(dir, "c.bxls");


            File.WriteAllText(file, @"
class a prototype = db-meta table=the.test
    item id=10 code=X name=XX
    item id=20 code=Y name=YY
    item id=30 code=Z name=ZZ
");

            File.WriteAllText(file2, @"
require data
TableBase test schema=the
    import IEntity
");
        }
        public void Setup()
        {
            DbInstallFactory.InitTestDatabase(DbName);
            dir   = FileSystemHelper.ResetTemporaryDirectory();
            file  = Path.Combine(dir, "a.bxls");
            file2 = Path.Combine(dir, "b.bxls");
            file3 = Path.Combine(dir, "c.bxls");

            var createtable = new ScriptTextDbUpdateTask("createtable", @"
create table dbo.test (
    id int  not null primary key,
    code nvarchar(255) not null unique default '',
    name nvarchar(255) not null default '',
    version datetime not null default getdate()
)
create table dbo.test1 (
    id int  not null primary key,
    code nvarchar(255) not null unique default '',
    name nvarchar(255) not null default '',
    version datetime not null default getdate(),
    test2 int not null  default 0
)
create table dbo.test2 (
    id int  not null primary key,
    code nvarchar(255) not null unique default '',
    name nvarchar(255) not null default '',
    version datetime not null default getdate(),
    test1 int not null default 0
)
GO
alter table dbo.test1 add constraint test2_fk foreign key (test2) references dbo.test2 (id)
GO
alter table dbo.test2 add constraint test1_fk foreign key (test1) references dbo.test1 (id) 
")
            {
                Database = DbName
            };

            createtable.Execute();
            Assert.AreEqual(TaskState.Success, createtable.State);

            File.WriteAllText(file, @"
class a prototype = db-meta table=dbo.test
    item id=10 code=X name=XX
    item id=20 code=Y name=YY
    item id=30 code=Z name=ZZ
");

            File.WriteAllText(file2, @"
class b prototype = db-meta table=dbo.test1
    item id=10 code=X name=XX test2=10
");
            File.WriteAllText(file3, @"
class c prototype = db-meta table=dbo.test2
    item id=10 code=Y name=YY test1=10 

");
            this.task = new BxlDataProjectDataUpdateTask(dir)
            {
                Database = DbName
            };
        }