Ejemplo n.º 1
0
        public static void ClassInitialize(TestContext testContext)
        {
            uow = new UnitOfWork();
            //uow.DbAdapter.DbConnection.Execute("DROP TABLE testobject;");
            //uow.DbAdapter.DbConnection.Execute("DROP TABLE counttest;");
            uow.DbAdapter.DbConnection.Execute("CREATE TABLE IF NOT EXISTS testobject (" +
                                               "ID BIGINT(20) AUTO_INCREMENT PRIMARY KEY," +
                                               "Title VARCHAR(45) NOT NULL UNIQUE," +
                                               "Description MEDIUMTEXT," +
                                               "StatusID INT NOT NULL," +
                                               "InputOn DATETIME NOT NULL," +
                                               "InputByID INT NOT NULL," +
                                               "IsActive TINYINT(1) NOT NULL) " +
                                               "ENGINE=InnoDB;");
            uow.DbAdapter.DbConnection.Execute("TRUNCATE TABLE testobject");
            uow.DbAdapter.DbConnection.Execute("CREATE TABLE IF NOT EXISTS counttest (" +
                                               "Number INT PRIMARY KEY," +
                                               "Name VARCHAR(45) NOT NULL UNIQUE) " +
                                               "ENGINE=InnoDB;");
            uow.DbAdapter.DbConnection.Execute("TRUNCATE TABLE counttest");
            CountTestRepository repo = uow.GetRepo <CountTestRepository>();

            repo.Add(new CountTest {
                Number = 1, Name = "Object 1"
            });
            repo.Add(new CountTest {
                Number = 2, Name = "Object 2"
            });
            repo.Add(new CountTest {
                Number = 3, Name = "Object 3"
            });
            repo.Add(new CountTest {
                Number = 4, Name = "Object 4"
            });
        }
        public static void ClassInitialize(TestContext testContext)
        {
            uow = new UnitOfWork();
            uow.DbAdapter.DbConnection.Execute("DROP TABLE testobject");
            uow.DbAdapter.DbConnection.Execute("DROP TABLE counttest");
            uow.DbAdapter.DbConnection.Execute("DROP TABLE datetest");
            uow.DbAdapter.DbConnection.Execute("DELETE FROM FM.CACHEDOTNET");
            uow.DbAdapter.DbConnection.Execute("" +
                                               "CREATE TABLE testobject (" +
                                               //"ID INT PRIMARY KEY, " + // ID column is added automatically
                                               "Title VARCHAR(45) NOT NULL UNIQUE," +
                                               "Description %String," +
                                               "StatusID INT NOT NULL," +
                                               "InputOn DATETIME NOT NULL," +
                                               "InputByID INT NOT NULL," +
                                               "IsActive TINYINT(1) NOT NULL) ");
            uow.DbAdapter.DbConnection.Execute("" +
                                               "CREATE TABLE counttest (" +
                                               "Number INT UNIQUE," +
                                               "Name VARCHAR(45) NOT NULL UNIQUE) ");
            uow.DbAdapter.DbConnection.Execute("" +
                                               "CREATE TABLE datetest (" +
                                               "Title VARCHAR(45) NOT NULL UNIQUE," +
                                               "Fileman_DateTime %FilemanTimeStamp," +
                                               "Fileman_Date %FilemanDate," +
                                               "Sql_DateTime DATETIME," +
                                               "Sql_Date DATE) ");
            CountTestRepository repo = uow.GetRepo <CountTestRepository>();

            repo.Add(new CountTest {
                Number = 1, Name = "Object 1"
            });
            repo.Add(new CountTest {
                Number = 2, Name = "Object 2"
            });
            repo.Add(new CountTest {
                Number = 3, Name = "Object 3"
            });
            repo.Add(new CountTest {
                Number = 4, Name = "Object 4"
            });
        }
        public static void ClassInitialize(TestContext testContext)
        {
            string dbPath = $"{Environment.CurrentDirectory}\\unittest.db";

            uow = new UnitOfWork(dbPath);
            if (!File.Exists(dbPath))
            {
                SQLiteConnection.CreateFile(dbPath);
            }

            uow.DbAdapter.DbConnection.Execute("CREATE TABLE IF NOT EXISTS testobject (" +
                                               "ID INTEGER PRIMARY KEY AUTOINCREMENT," +
                                               "Title TEXT NOT NULL UNIQUE," +
                                               "Description TEXT," +
                                               "StatusID INTEGER NOT NULL," +
                                               "InputOn TEXT NOT NULL," +
                                               "InputByID INTEGER NOT NULL," +
                                               "IsActive INTEGER NOT NULL);");
            uow.DbAdapter.DbConnection.Execute("DELETE FROM testobject");
            uow.DbAdapter.DbConnection.Execute("CREATE TABLE IF NOT EXISTS counttest (" +
                                               "Number INTEGER PRIMARY KEY," +
                                               "Name TEXT NOT NULL UNIQUE);");
            uow.DbAdapter.DbConnection.Execute("DELETE FROM counttest");
            CountTestRepository repo = uow.GetRepo <CountTestRepository>();

            repo.Add(new CountTest {
                Number = 1, Name = "Object 1"
            });
            repo.Add(new CountTest {
                Number = 2, Name = "Object 2"
            });
            repo.Add(new CountTest {
                Number = 3, Name = "Object 3"
            });
            repo.Add(new CountTest {
                Number = 4, Name = "Object 4"
            });
        }
        public static void ClassInitialize(TestContext testContext)
        {
            uow = new UnitOfWork();
            //uow.DbAdapter.DbConnection.Execute("DROP TABLE testobject;");
            //uow.DbAdapter.DbConnection.Execute("DROP TABLE counttest;");
            uow.DbAdapter.DbConnection.Execute("" +
                                               "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='testobject' AND xtype='U')" +
                                               "CREATE TABLE testobject (" +
                                               "ID BIGINT IDENTITY(1,1) PRIMARY KEY," +
                                               "Title NVARCHAR(45) NOT NULL UNIQUE," +
                                               "Description NVARCHAR(MAX)," +
                                               "StatusID INT NOT NULL," +
                                               "InputOn DATETIME NOT NULL," +
                                               "InputByID INT NOT NULL," +
                                               "IsActive TINYINT NOT NULL)");
            uow.DbAdapter.DbConnection.Execute("TRUNCATE TABLE testobject");
            uow.DbAdapter.DbConnection.Execute("" +
                                               "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='counttest' AND xtype='U')" +
                                               "CREATE TABLE counttest " +
                                               "(" +
                                               "Number INT PRIMARY KEY," +
                                               "Name VARCHAR(45) NOT NULL UNIQUE)");
            uow.DbAdapter.DbConnection.Execute("TRUNCATE TABLE counttest");
            CountTestRepository repo = uow.GetRepo <CountTestRepository>();

            repo.Add(new CountTest {
                Number = 1, Name = "Object 1"
            });
            repo.Add(new CountTest {
                Number = 2, Name = "Object 2"
            });
            repo.Add(new CountTest {
                Number = 3, Name = "Object 3"
            });
            repo.Add(new CountTest {
                Number = 4, Name = "Object 4"
            });
        }