예제 #1
0
        }   // MergeOutputFQFN


        private static void ReportDetailsTests ( bool pfTestSorting )
        {
            const uint OUT_OF_ORDER = 900;

            string strTaskName = System.Reflection.MethodBase.GetCurrentMethod ( ).Name;

            Console.WriteLine (
                Properties.Resources.IDS_MSG_BATCH ,
                strTaskName ,
                Properties.Resources.IDS_MSG_BEGIN ,
                Environment.NewLine );

            if ( pfTestSorting )
                FormatStringParsing_Drills.TestFormatItemCounters ( );

            ReportDetails rdColl = new ReportDetails ( );

            if ( pfTestSorting )
                Console.WriteLine (
                    Properties.Resources.MSG_REPORT_DETAILS_SELECTIVELY_OVERRIDDEN ,
                    Environment.NewLine );
            else
                Console.WriteLine (
                    Properties.Resources.MSG_REPORT_DETAILS_AUTO_ORDERED ,
                    Environment.NewLine );

            rdColl.Add ( new ReportDetail (
                Properties.Resources.IDS_MSG_REPORT_LABEL_1 ,
                Properties.Resources.IDS_MSG_REPORT_LABEL_1.Length ,
                Properties.Resources.IDS_MSG_REPORT_LABEL_1.Length.ToString ( ) ) );
            rdColl.Add ( new ReportDetail (
                Properties.Resources.IDS_MSG_REPORT_LABEL_2 ,
                Properties.Resources.IDS_MSG_REPORT_LABEL_2.Length ,
                Properties.Resources.IDS_MSG_REPORT_LABEL_2.Length.ToString ( ) ) );
            rdColl.Add ( new ReportDetail (
                Properties.Resources.IDS_MSG_REPORT_LABEL_3 ,
                Properties.Resources.IDS_MSG_REPORT_LABEL_3.Length ,
                Properties.Resources.IDS_MSG_REPORT_LABEL_3.Length.ToString ( ) ,
                ( ReportDetail.ItemDisplayOrder ) OUT_OF_ORDER ) );                                   // This one is intentionally out of order.
            rdColl.Add ( new ReportDetail (
                Properties.Resources.IDS_MSG_REPORT_LABEL_4 ,
                Properties.Resources.IDS_REALLY_LONG_STRING.Length ) ); // Leave the display value NULL.

            Console.WriteLine (
                Properties.Resources.IDS_MSG_LONGEST_LABEL ,
                rdColl.WidthOfWidestLabel );
            Console.WriteLine (
                Properties.Resources.IDS_MSG_LONGEST_VALUE ,
                rdColl.WidthOfWidestValue ,
                Environment.NewLine );

            if ( pfTestSorting )
            {   // The sorting pass shows it twice.
                Console.WriteLine (
                    Properties.Resources.MSG_REPORT_DETAILS_UNSORTED ,
                    Environment.NewLine );
            }   // if ( pfTestSorting )

            //  ----------------------------------------------------------------
            //  Since the value of this property is computed on demand by
            //  enumerating the collection, it is more efficient to hoist it out
            //  of the loop that also enumerates it. This change improves the
            //  performance of the foreach loop that follows it from an O(n^2)
            //  operation to an O(n) operation.
            //
            //  Since the typical size of these report item collections is on
            //  tho order of a few hundred items or less, the computational 
            //  impact of this change is too small to measure without running
            //  hundreds or thousands of iterations. Nevertheless, when it's so
            //  easy to do so, I believe that any operation should be designed
            //  to scale as well as possible.
            //  ----------------------------------------------------------------

            int intWidthOfWidestLabel = rdColl.WidthOfWidestLabel;
            int intWidthOfWidestValue = rdColl.WidthOfWidestValue;

            foreach ( ReportDetail rdItem in rdColl )
            {
                Console.WriteLine (
                    ReportDetail.DEFAULT_FORMAT ,
                    intWidthOfWidestLabel ,
                    rdItem.GetPaddedValue (
                        intWidthOfWidestValue ,
                        FormatItem.Alignment.Right ,
                        NumericFormats.DECIMAL ) );
            }   // foreach ( ReportDetail rdItem in rdColl )

            if ( pfTestSorting )
            {   // The second pass follows a sort.
                Console.WriteLine (
                    Properties.Resources.MSG_REPORT_DETAILS_UNSORTED ,
                    Environment.NewLine );

                rdColl.Sort ( );    // ReportDetails implements IComparable. Use it.

                foreach ( ReportDetail rdItem in rdColl )
                {
                    Console.WriteLine (
                        ReportDetail.DEFAULT_FORMAT ,
                        rdItem.GetPaddedLabel ( intWidthOfWidestLabel ) ,
                        rdItem.GetPaddedValue (
                            intWidthOfWidestValue ,
                            FormatItem.Alignment.Right ,
                            NumericFormats.DECIMAL ) );
                }   // foreach ( ReportDetail rdItem in rdColl )
            }   // if ( pfTestSorting )

            Console.WriteLine (
                Properties.Resources.IDS_MSG_BATCH ,
                strTaskName ,
                Properties.Resources.IDS_MSG_DONE ,
                Environment.NewLine );
        }   // private void ReportDetailsTests
예제 #2
0
        internal static int s_intNArgs;						// This gets the count of command line arguments.


        static void Main ( string [ ] args )
        {
            rs_appThis.DisplayBOJMessage ( );
            Console.WriteLine (
                SharedUtl4_TestStand.Properties.Resources.IDS_DATA_DIRECTORY_NAME ,
                rs_strDataDirectory );
            rs_appThis.BaseStateManager.LoadErrorMessageTable (
                new string [ ]
                {
                    Properties.Resources.ERRMSG_SUCCESS ,
                    Properties.Resources.ERRMSG_RUNTIME
                } );
            rs_appThis.BaseStateManager.AppExceptionLogger.OptionFlags =
                rs_appThis.BaseStateManager.AppExceptionLogger.OptionFlags
                | ExceptionLogger.OutputOptions.EventLog
                | ExceptionLogger.OutputOptions.Stack
                | ExceptionLogger.OutputOptions.StandardOutput;
            InitializeTestSelections ( args );

            try
            {
                if ( DoThisTest ( CHOICE_MAXSTRINGLENGTH ) )
                    MaxStringLength_Tests ( );

                if ( DoThisTest ( CHOICE_MERGENEWITEMSINTOARRAY ) )
                    MergeNewItemsIntoArray_Tests ( );

                if ( DoThisTest ( CHOICE_DIGESTFILE ) )
                    DigestFileTests ( );

                if ( DoThisTest ( CHOICE_REPORTDETAILS ) )
                {
                    ReportDetailsTests ( TEST_UNSORTED );
                    ReportDetailsTests ( TEST_SORTED );
                }   // if ( DoThisTest ( CHOICE_REPORTDETAILS ) )

                if ( DoThisTest ( CHOICE_REPORTHELPERS ) )
                    ReportHelpersTests ( );

                if ( DoThisTest ( CHOICE_FORMAT_ITEM_GEN ) )
                    FormatStringParsing_Drills.TestFormatItemBuilders ( );

				if ( DoThisTest ( CHOICE_ASCII_TABLE_GEN ) )
					FormatStringParsing_Drills.ASCII_Table_Gen ( );
            }
            catch ( Exception errAllKinds )
            {
				rs_appThis.BaseStateManager.AppExceptionLogger.ReportException ( errAllKinds );
                rs_appThis.BaseStateManager.AppReturnCode = ERR_RUNTIME;
            }
            finally
            {
                if ( rs_appThis.BaseStateManager.AppReturnCode == MagicNumbers.ERROR_SUCCESS )
                {
                    rs_appThis.NormalExit (
                        ConsoleAppStateManager.NormalExitAction.WaitForOperator );
                }   // TRUE (expected outcome) block, if ( rs_appThis.BaseStateManager.AppReturnCode == MagicNumbers.ERROR_SUCCESS )
                else
                {
                    rs_appThis.ErrorExit (
                        ( uint ) rs_appThis.BaseStateManager.AppReturnCode );
                }   // FALSE (exception) block, if ( rs_appThis.BaseStateManager.AppReturnCode == MagicNumbers.ERROR_SUCCESS )
            }
        }   // static void Main