Exemplo n.º 1
0
 internal virtual void UpdateColumnTypes(Database database, Section.SectionType sectionType)
 {
     Section section = testCase.GetSection(sectionType);
     foreach (string tableName in section.TableNames)
     {
         Table table = section.GetTable(tableName);
         UpdateColumnTypes(database, table);
     }
 }
Exemplo n.º 2
0
 public void Validate()
 {
     InitializeSearchKey();
     using (Database database = new Database())
     {
         Section section = Section;
         DataSet dataSet = GetDataSet(Section.SectionType.DataAsExpected);
         foreach (DataTable expectedDataTable in dataSet.Tables)
         {
             List<string> keyColumns = GetKeyColumns(section, expectedDataTable);
             Table expectedTable = section.GetTable(expectedDataTable.TableName);
             DataTable actualDataTable = database.Select(keyColumns, expectedDataTable, expectedTable);
             Validate(actualDataTable);
         }
     }
 }
Exemplo n.º 3
0
 private static void UpdateColumnTypes(Database database, Table table)
 {
     DataTable metaData = database.GetMetaData(table);
     foreach (Column column in table.Columns)
     {
         if (column != null)
         {
             DataColumn dataColumn = metaData.Columns[column.Name];
             if (dataColumn == null)
             {
                 throw new ConfigException("M_Fixture_Temp_DatabaseOperator_Column_NotFound",
                     metaData.TableName, column.Name, table);
             }
             if (column.Type == null && column.ComponentType == null)
             {
                 column.SetType(dataColumn.DataType);
             }
         }
     }
 }
Exemplo n.º 4
0
        public void Setup()
        {
            if (DeleteSection == null && CreateSection == null)
            {
                return;
            }

            using (Database database = new Database())
            {
                if (DeleteSection != null && DeleteSection.HasTable())
                {
                    DataSet dataSet = GetDataSet(Section.SectionType.DataToDelete);
                    database.Delete(dataSet, DeleteSection);
                }

                if (CreateSection != null && CreateSection.HasTable())
                {
                    UpdateColumnTypes(database, Section.SectionType.DataToCreate);
                    DataSet dataSet = GetDataSet(Section.SectionType.DataToCreate);
                    database.Insert(dataSet, CreateSection);
                }
                database.Commit();
            }
        }
Exemplo n.º 5
0
        public void 指定されたデータをデータベーステーブルに投入できる_SQLServer()
        {
            // setup
            Loggi.DebugEnabled = true;

            // when
            fixtureBook.Setup();

            // then
            using (Database database = new Database())
            {
                DataTable table = database.ExecuteQuery("select * from TypesTable order by Id");
                fixtureBook.Validate(table, "TypesTable");
            }
        }
Exemplo n.º 6
0
        public void 指定されたデータをデータベーステーブルに投入できる_Oracle()
        {
            // setup
            Loggi.DebugEnabled = true;

            // when
            fixtureBook.Setup();

            // then
            using (Database database = new Database())
            {
                database.Use("Oracle");
                DataTable table = database.ExecuteQuery("select * from TYPES_TABLE order by ID");
                fixtureBook.Validate(table, "TYPES_TABLE");
            }
        }
Exemplo n.º 7
0
 private void ValidateDatabase(int expect)
 {
     using (Database database = new Database())
     {
         DataTable table = database.ExecuteQuery("select int1 from TypesTable");
         Assert.AreEqual(1, table.Rows.Count);
         Assert.AreEqual(expect, table.Rows[0]["int1"]);
     }
 }
Exemplo n.º 8
0
 private void UpdateDatabase(int expect)
 {
     using (Database database = new Database())
     {
         database.ExecuteNonQuery("update TypesTable set int1 = " + expect);
         database.Commit();
     }
 }
Exemplo n.º 9
0
        public void ValidateメソッドはSetupメソッドの暗黙呼び出しを行わないこと()
        {
            // setup
            Loggi.DebugEnabled = true;
            using (Database database = new Database())
            {
                database.ExecuteNonQuery("delete from TypesTable");
                database.Commit();
            }
            FixtureBook fixtureBook = new FixtureBook();

            // when
            Dictionary<string, string> obj = new Dictionary<string, string>();
            obj["Id"] = "1";
            fixtureBook.Validate(obj);

            // then
            using (Database database = new Database())
            {
                Assert.AreEqual(0, database.ExecuteQuery("select * from TypesTable").Rows.Count);
            }

            // when
            fixtureBook.Setup();

            // then
            using (Database database = new Database())
            {
                Assert.AreEqual(1, database.ExecuteQuery("select * from TypesTable").Rows.Count);
            }
        }
Exemplo n.º 10
0
        public void ValidateStorageの呼び出し時にはSetupメソッドの暗黙呼び出しはされないこと()
        {
            // setup
            Loggi.DebugEnabled = true;
            using (Database database = new Database())
            {
                database.ExecuteNonQuery("delete from TypesTable");
                database.Commit();
            }
            FixtureBook fixtureBook = new FixtureBook();

            // when
            try
            {
                fixtureBook.ValidateStorage();
                throw new Exception("ここにはこない");
            }
            catch (AssertFailedException e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 11
0
        private void 検索列指定をしてデータベーステーブルの状態が予想結果と異なることをチェックできる_SQLServer(string column, object value, string valueAsText)
        {
            // setup
            fixtureBook.Setup();
            using (Database database = new Database())
            {
                DbCommand command = database.CreateCommand("update TypesTable set " + column + "=@" + column + " where Id=2");
                database.AddParameter(command, column, null, value);
                database.ExecuteNonQuery(command);
                database.Commit();
            }

            try
            {
                // when
                fixtureBook.ValidateStorage();
                Assert.Fail("ここにはこない");
            }
            catch (Exception e)
            {
                // then
                string message = e.Message;
                Console.WriteLine(message);
                Assert.IsTrue(message.IndexOf(column) > -1);
                Assert.IsTrue(message.IndexOf("<" + valueAsText + ">") > -1);
            }
        }
Exemplo n.º 12
0
        public void 検索列指定をせずにデータベーステーブルの状態が予想結果と異なることをチェックできる_SQLServer()
        {
            // setup
            Loggi.DebugEnabled = true;
            fixtureBook.Setup();
            using (Database database = new Database())
            {
                database.ExecuteNonQuery("update TypesTable set bigint1=2 where Id=2");
                database.Commit();
            }

            try
            {
                // when
                fixtureBook.ValidateStorage();
                Assert.Fail("ここにはこない");
            }
            catch (Exception e)
            {
                // then
                string message = e.Message;
                Console.WriteLine(message);
                Assert.IsTrue(Regex.IsMatch(message, ".*TypesTable.*TypesTable.*"));
                Assert.IsTrue(message.IndexOf("*") > -1);
            }
        }
Exemplo n.º 13
0
        public void 指定した検索列が存在しない場合はエラー_SQLServer()
        {
            // setup
            Loggi.DebugEnabled = true;
            fixtureBook.Setup();
            using (Database database = new Database())
            {
                database.ExecuteNonQuery("delete from TypesTable");
                database.Commit();
            }

            try
            {
                // when
                fixtureBook.ValidateStorage();
                Assert.Fail("ここにはこない");
            }
            catch (Exception e)
            {
                // then
                string message = e.Message;
                Console.WriteLine(message);
                Assert.IsTrue(Regex.IsMatch(message, ".*TypesTable.*TypesTable.*"));
                Assert.IsTrue(message.IndexOf("*") == -1);
            }
        }
Exemplo n.º 14
0
        public void 削除済み指定のデータが存在しない場合は正常終了となるその2_Oracle()
        {
            // setup
            Loggi.DebugEnabled = true;
            fixtureBook.Setup();
            using (Database database = new Database())
            {
                database.Use("Oracle");
                database.ExecuteNonQuery("delete from TYPES_TABLE where ID = 2");
                database.Commit();
            }

            // expect
            fixtureBook.ValidateStorage();
        }