Ejemplo n.º 1
0
        private static void PrintSQL(DbCommand command)
        {
            if (Loggi.DebugEnabled)
            {
                StringBuilder sqlText = new StringBuilder();
                foreach (DbParameter parameter in command.Parameters)
                {
                    if (sqlText.Length == 0)
                    {
                        sqlText.Append(command.CommandText).Append(" - ");
                    }
                    else
                    {
                        sqlText.Append(", ");
                    }
                    sqlText.Append(parameter.Value);
                }

                if (sqlText.Length == 0)
                {
                    sqlText.Append(command.CommandText);
                }
                Loggi.Debug("SQL: " + sqlText.ToString());
            }
        }
Ejemplo n.º 2
0
        public void Validate <TException>(Action action, string typeName) where TException : Exception
        {
            bool isNormalEnd = false;

            try
            {
                action();
                isNormalEnd = true;
            }
            catch (TException e)
            {
                Loggi.Debug(e);
                object   obj    = e;
                Delegate editor = GetExceptionEditor(e.GetType());
                if (editor != null)
                {
                    obj = editor.DynamicInvoke(e);
                }
                Validate(obj, typeName);
            }

            if (isNormalEnd)
            {
                Assertie.Fail("M_Fixture_Temp_ObjectValidator_Exception", typeof(TException).Name);
            }
        }
Ejemplo n.º 3
0
 private void Initialize(FixtureInfo fixtureInfo)
 {
     book     = Book.GetInstance(fixtureInfo.FilePath);
     sheet    = book.GetSheet(fixtureInfo.SheetName);
     testCase = sheet.GetCase(fixtureInfo.TestCaseName);
     Loggi.Debug("FixtureBook : Case : " + testCase);
 }
Ejemplo n.º 4
0
        private void InitializeProvider(string databaseName)
        {
            ConnectionStringSettings settings;

            if (DatabaseConnection.Default.Equals(databaseName))
            {
                if (DatabaseConnectionManager.ConnectionStrings.Count == 0)
                {
                    throw new ConfigException("M_Fixture_Temp_DatabaseConnection_NoConnectionSettings");
                }
                settings = DatabaseConnectionManager.ConnectionStrings[0];
            }
            else
            {
                settings = DatabaseConnectionManager.Find(databaseName);
                if (settings == null)
                {
                    throw new ConfigException("M_Fixture_Temp_DatabaseConnection_NoSuchName", databaseName);
                }
            }

            provider         = settings.ProviderName;
            connectionString = settings.ConnectionString;
            Loggi.Debug("Connection: " + settings.Name + ", providerName=" + provider + ", connectionString=" + connectionString);

            factory = DbProviderFactories.GetFactory(provider);
            if (provider.IndexOf("Oracle") > -1)
            {
                parameterPrefix = ':';
            }
            else
            {
                IsSQLServer = true;
            }
        }
Ejemplo n.º 5
0
        private string[] GetTableNamesFrom(DataSet dataSet)
        {
            List <string> tableNames = new List <string>();

            if (ValidateTableNames(dataSet))
            {
                foreach (DataTable table in dataSet.Tables)
                {
                    tableNames.Add(table.TableName);
                }
            }
            else if (dataSet.Tables.Count > Section.TableNames.Count)
            {
                Assertie.Fail(
                    "M_Fixture_Temp_ObjectValidator_AssertTableNumberImp",
                    Section.TableNames.Count, dataSet.Tables.Count, Section);
            }
            else
            {
                string messageFormat = Resi.Get("M_Fixture_Temp_ObjectValidator_UseTableOrder");
                Loggi.Warn(String.Format(messageFormat, Section));
                for (int i = 0; i < dataSet.Tables.Count; i++)
                {
                    Loggi.Warn("DataSet.Table[" + i + "] = " + Section.TableNames[i]);
                    tableNames.Add(Section.TableNames[i]);
                }
            }
            return(tableNames.ToArray());
        }
Ejemplo n.º 6
0
 private void Output(string cellReference, string formattedValue)
 {
     if (cellParser.DebugEnabled)
     {
         Loggi.Debug("[" + cellReference + "]" + formattedValue);
     }
     cellParser.Parse(ToRow(cellReference), ToColumn(cellReference), formattedValue);
 }
Ejemplo n.º 7
0
        public void Error_stringはErrorレベルでログ出力を行う()
        {
            // when
            Loggi.Error("aaa");

            // then
            traceListener.AssertMessage("Error", "aaa", null);
        }
Ejemplo n.º 8
0
        public void Info_stringはInformationレベルでログ出力を行う()
        {
            // when
            Loggi.Info("aaa");

            // then
            traceListener.AssertMessage("Information", "aaa", null);
        }
Ejemplo n.º 9
0
        public void Warn_stringはWarningレベルでログ出力を行う()
        {
            // when
            Loggi.Warn("aaa");

            // then
            traceListener.AssertMessage("Warning", "aaa", null);
        }
Ejemplo n.º 10
0
        public void Debug_stringはDebugEnabledがfalseの場合ログ出力を行わない()
        {
            // setup
            Loggi.DebugEnabled = false;

            // when
            Loggi.Debug("aaa");

            // then
            traceListener.AssertMessage(null, null, null);
        }
Ejemplo n.º 11
0
        public void Debug_stringはDebugEnabledがtrueの場合ログ出力を行う()
        {
            // setup
            Loggi.DebugEnabled = true;

            // when
            Loggi.Debug("aaa");

            // then
            traceListener.AssertMessage(null, "aaa", null);
        }
Ejemplo n.º 12
0
 private void Initialize(Type testClass, string bookPath, string sheetName, string testCaseName)
 {
     this.testClass = testClass;
     this.book      = Book.GetInstance(testClass, bookPath);
     this.sheet     = book.GetSheet(sheetName);
     this.testCase  = sheet.GetCase(testCaseName);
     foreach (Type exceptionType in defaultExceptionEditors.Keys)
     {
         this.testCase.RegisterExceptionEditor(exceptionType, defaultExceptionEditors[exceptionType]);
     }
     Loggi.Debug("FixtureBook : Case : " + this.testCase);
 }
Ejemplo n.º 13
0
 private object DynamicInvoke(Type targetClass, string targetMethod, Type[] targetMethodParameter)
 {
     try
     {
         return(DynamicInvokeInternal(targetClass, targetMethod, targetMethodParameter));
     }
     catch (TargetInvocationException e)
     {
         Loggi.Debug(e);
         throw e.InnerException;
     }
 }
Ejemplo n.º 14
0
 private object DynamicInvoke(Delegate action, Type[] types)
 {
     try
     {
         return(action.DynamicInvoke(GetParameters(types)));
     }
     catch (TargetInvocationException e)
     {
         Loggi.Debug(e);
         throw e.InnerException;
     }
 }
Ejemplo n.º 15
0
 private void SetEnabledIdentityInsert(bool enabled, string tableName)
 {
     if (connection.IsSQLServer && HasIdentityColumn(tableName))
     {
         try
         {
             string onOff = enabled ? " ON" : " OFF";
             ExecuteNonQuery(connection.CreateCommand("SET IDENTITY_INSERT " + tableName + onOff));
         }
         catch (Exception e)
         {
             Loggi.Warn(e);
         }
     }
 }
Ejemplo n.º 16
0
        public void Info_ExceptionはInformationレベルでログ出力を行う()
        {
            // setup
            try
            {
                throwException("aaa");
            }
            catch (Exception e)
            {
                // when
                Loggi.Info(e);

                // then
                traceListener.AssertMessage("Information", "aaa", e);
            }
        }
Ejemplo n.º 17
0
        public void Error_string_ExceptionはErrorレベルでログ出力を行う()
        {
            // setup
            try
            {
                throwException("eee");
            }
            catch (Exception e)
            {
                // when
                Loggi.Error("aaa", e);

                // then
                traceListener.AssertMessage("Error", "aaa", e);
            }
        }
Ejemplo n.º 18
0
        public void Warn_string_ExceptionはWarningレベルでログ出力を行う()
        {
            // setup
            try
            {
                throwException("eee");
            }
            catch (Exception e)
            {
                // when
                Loggi.Warn("aaa", e);

                // then
                traceListener.AssertMessage("Warning", "aaa", e);
            }
        }
Ejemplo n.º 19
0
        public void Debug_string_ExceptionはDebugEnabledがfalseの場合ログ出力を行わない()
        {
            // setup
            Loggi.DebugEnabled = false;
            try
            {
                throwException("eee");
            }
            catch (Exception e)
            {
                // when
                Loggi.Debug("aaa", e);

                // then
                traceListener.AssertMessage(null, null, null);
            }
        }
Ejemplo n.º 20
0
        public void Debug_ExceptionはDebugEnabledがtrueの場合ログ出力を行う()
        {
            // setup
            Loggi.DebugEnabled = true;
            try
            {
                throwException("aaa");
            }
            catch (Exception e)
            {
                // when
                Loggi.Debug(e);

                // then
                traceListener.AssertMessage(null, "aaa", e);
            }
        }
Ejemplo n.º 21
0
        public override void Validate <TException>(Action action, string typeName)
        {
            bool isNormalEnd = false;

            try
            {
                action();
                isNormalEnd = true;
            }
            catch (TException e)
            {
                Loggi.Debug(e);
                Validate(e, typeName);
            }

            if (isNormalEnd)
            {
                Assertie.Fail("M_Fixture_Temp_ObjectValidator_Exception", typeof(TException).Name);
            }
        }