Ejemplo n.º 1
0
 /// <summary>
 /// Builds a row column based on the column data.
 /// </summary>
 /// <param name="columnData">Information on how to build one column of the row.</param>
 protected virtual void AddColumn(ColumnDef columnData)
 {
     if ((++count) > 1) {
     rowString.Append(this.info.SyntaxData.ColumnDelimiter);
     }
     this.BuildColumn(columnData);
 }
 /// <summary>Builds a SQL type string if # found and MaxLength larger than 0.</summary>
 /// <param name="columnDef">Column metadata object.</param>
 /// <returns>
 /// Built type string if constraints are present or the ColumnDef.SqlRepresentation.
 /// </returns>
 private String BuildColumnType(ColumnDef columnDef)
 {
     Regex reg = new Regex("[" + typeSizeToken + "]");
     if (reg.IsMatch(columnDef.SqlRepresentation) && columnDef.MaxLength > 0) {
     return reg.Replace(columnDef.SqlRepresentation, columnDef.MaxLength.ToString());
     }
     return columnDef.SqlRepresentation;
 }
        /// <summary>Called by the base class to build one column's information.</summary>
        /// <param name="columnDef">Metadat for one column.</param>
        protected override void BuildColumn(ColumnDef columnDef)
        {
            // columnDef.MaxLength

            this.rowString
            .Append(columnDef.Name)
            .Append(" ")
            .Append(this.BuildColumnType(columnDef));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Implements the method from IQueryable. Allows the objects data to be querried.
 /// </summary>
 /// <param name="columnDef">Column metadata.</param>
 /// <param name="info">Log metadata.</param>
 /// <returns>The string format of the data indexed by the column's metadata.</returns>
 public String GetValue(ColumnDef columnDef, LogInfo info)
 {
     if (columnDef.Name.CompareTo("SuccessCount") == 0) {
     return Convert.ToString(this.successCount);
     }
     else if (columnDef.Name.CompareTo("FailInitCount") == 0) {
     return Convert.ToString(this.failInitCount);
     }
     else if (columnDef.Name.CompareTo("FailSetupCount") == 0) {
     return Convert.ToString(this.failSetupCount);
     }
     else if (columnDef.Name.CompareTo("FailTestCount") == 0) {
     return Convert.ToString(this.failTestCount);
     }
     else if (columnDef.Name.CompareTo("FailCleanupCount") == 0) {
     return Convert.ToString(this.failCleanupCount);
     }
     else if (columnDef.Name.CompareTo("NotExistCount") == 0) {
     return Convert.ToString(this.notExistCount);
     }
     else if (columnDef.Name.CompareTo("UncheckedExceptionCount") == 0) {
     return Convert.ToString(this.exceptionCount);
     }
     else if (columnDef.Name.CompareTo("JavaErrorCount") == 0) {
     return Convert.ToString(this.assertCount);
     }
     else if (columnDef.Name.CompareTo("TotalCount") == 0) {
     return Convert.ToString(
             this.failInitCount + this.failSetupCount + this.failCleanupCount +
             this.failTestCount + this.successCount   + this.notExistCount + exceptionCount +
             this.assertCount
         );
     }
     else if (columnDef.Name.CompareTo("RunId") == 0) {
     // Do NOT do a truncate check against the run id.  The output would become useless to identify.
     // Better let it to fail on length limit.
     return new StringBuilder()
         .Append(info.SyntaxData.StringDelimiter)
         .Append(TestEngine.GetInstance().GetRunId())
         .Append(info.SyntaxData.StringDelimiter)
         .ToString();
     }
     else
     {
     StringBuilder sb = new StringBuilder( 200 );
     sb.Append( "Illegal column name:" ).Append(columnDef.Name);
     sb.Append( " - Allowable values are:" );
     sb.Append( "SuccessCount, FailInitCount, FailSetupCount, FailTestCount, " );
     sb.Append( "FailCleanupCount, NotExistCount, RunId, TotalCount" );
     throw new InputException( sb.ToString() );
     }
 }
Ejemplo n.º 5
0
 // Wrap string data in string delimiters quotes.
 private string WrapStringData(string str, ColumnDef columnDef, LogInfo info)
 {
     return new StringBuilder(25)
     .Append(info.SyntaxData.StringDelimiter)
     .Append(this.TrimToSize(str, columnDef))
     .Append(info.SyntaxData.StringDelimiter).ToString();
 }
Ejemplo n.º 6
0
 private string TrimToSize(string str, ColumnDef columnDef)
 {
     if (columnDef.IsDataToBeTruncated()) {
     if (str.Length > columnDef.MaxLength) {
         return str.Substring(0, columnDef.MaxLength);
     }
     }
     return str;
 }
Ejemplo n.º 7
0
 // Assemble the verbose buffer message.
 private string BuildVerboseBufferStr(ColumnDef columnDef, LogInfo info)
 {
     //TODO Look at moving this to an output level object.
     StringBuilder sb = new StringBuilder();
     sb.Append(info.SyntaxData.StringDelimiter);
     if (this.VerboseBuffer.Length > 0)
     {
     StringBuilder tmpSb = new StringBuilder();
     tmpSb.Append(info.OutputData.NewLineSequence)
         .Append("-----------------------------------").Append(info.OutputData.NewLineSequence)
         .Append(this.VerboseBuffer.ToString())
         .Append(info.OutputData.NewLineSequence);
     sb.Append(this.TrimToSize(tmpSb.ToString(), columnDef));
     }
     return sb.Append(info.SyntaxData.StringDelimiter).ToString();
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Implements the ILogable interface GetValue.  This allows the object to be queried for 
        /// its values.
        /// </summary>
        /// <param name="columnDef">Column metadata.</param>
        /// <param name="info">Log metadata</param>
        /// <returns>The string representation of the queried data field.</returns>
        public String GetValue(ColumnDef columnDef, LogInfo info)
        {
            if (columnDef.Name.CompareTo("Identifier") == 0) {
            return this.WrapStringData(this.Id, columnDef, info);
            }
            else if (columnDef.Name.CompareTo("Description") == 0) {
            return this.WrapStringData(this.desc, columnDef, info);
            }
            else if (columnDef.Name.CompareTo("Status") == 0) {
            return this.WrapStringData(this.Status.ToString(), columnDef, info);
            }
            else if (columnDef.Name.CompareTo("Message") == 0) {
            return this.WrapStringData(this.MsgBuffer.ToString(), columnDef, info);
            }
            else if (columnDef.Name.CompareTo("InitTime") == 0) {
            return Convert.ToString(this.initTime);
            }
            else if (columnDef.Name.CompareTo("SetupTime") == 0) {
            return Convert.ToString(this.setupTime);
            }
            else if (columnDef.Name.CompareTo("ExecTime") == 0) {
            return Convert.ToString(this.execTime);
            }
            else if (columnDef.Name.CompareTo("CleanupTime") == 0) {
            return Convert.ToString(this.cleanupTime);
            }
            else if (columnDef.Name.CompareTo("RunId") == 0) {
            // Do NOT truncate run id or output could be useless as identifier. Better let it to fail.
            return new StringBuilder()
                .Append(info.SyntaxData.StringDelimiter)
                .Append(TestEngine.GetInstance().GetRunId())
                .Append(info.SyntaxData.StringDelimiter).ToString();
            }
            else if (columnDef.Name.CompareTo("VerboseMessage") == 0) {
            return this.BuildVerboseBufferStr(columnDef, info);
            }
            else
            {
            StringBuilder sb = new StringBuilder( 200 );
            sb.Append("Illegal column name:").Append(columnDef.Name)
                .Append(" - Allowable values are:")
                .Append("ID, Description, Status, InitTime,SetupTime, ExecTime, CleanupTime, RunId Message, VerboseMessage");
            throw new InputException(sb.ToString());

            // TODO - Replace with our own exceptions.
            throw new System.ArgumentException(sb.ToString());
            }
        }
 /// <see cref="RowBuilder.BuildColumn"/>
 protected override void BuildColumn(ColumnDef columnDef)
 {
     this.rowString.Append(queryable.GetValue(columnDef, this.info));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Override to format each column's data before it is added to the row string.
 /// </summary>
 /// <param name="columnDef">The metadata for the column's data.</param>
 protected abstract void BuildColumn(ColumnDef columnDef);