Beispiel #1
0
		}	// private static void ListGUIDsInOrder


        private static void TestSpecificBits ( )
        {
            const int STACK = 4;                    // Bit 3
            const int STDERR = 32;                  // Bit 6
            const int METHOD = 1;                   // Bit 1
            const int SOURCE = 2;                   // Bit 2
            const int EVENTLOG = 8;                 // Bit 4
            const int STDOUT = 16;                  // Bit 5

            const int BIT_6 = 6;

            const string MSG_BEGIN = @"Begin TestSpecificBits{0}";
            const string MSG_DONE = @"{0}TestSpecificBits Done{0}";
            const string MSG_TPL_ANTE = @"{3}    Test {0,2} Ante = {1,2} - b32 = {2}";
            const string MSG_TPL_POST = @"            Post = {0,2} - b32 = {1}";
            const string MSG_TPL_BIT_NUMBER = @"    Test {0,2}: Bit Value = {1,3} ({1:x8}) - Bit Number = {2,2}";

            int rintTestNbr = 1;

            Console.WriteLine (
                MSG_BEGIN ,
                Environment.NewLine );

            UInt32 uintBitNumber = BitArray32.BitNumber ( STACK );
            Console.WriteLine (
                MSG_TPL_BIT_NUMBER ,
                rintTestNbr++ ,
                STACK ,
                uintBitNumber );

            uintBitNumber = BitArray32.BitNumber ( STDERR );
            Console.WriteLine (
                MSG_TPL_BIT_NUMBER ,
                rintTestNbr++ ,
                STDERR ,
                uintBitNumber );

            uintBitNumber = BitArray32.BitNumber ( EVENTLOG );
            Console.WriteLine (
                MSG_TPL_BIT_NUMBER ,
                rintTestNbr++ ,
                EVENTLOG ,
                uintBitNumber );

            uintBitNumber = BitArray32.BitNumber ( STDOUT );
            Console.WriteLine (
                MSG_TPL_BIT_NUMBER ,
                rintTestNbr++ ,
                STDOUT ,
                uintBitNumber );

            uintBitNumber = BitArray32.BitNumber ( METHOD );
            Console.WriteLine (
                MSG_TPL_BIT_NUMBER ,
                rintTestNbr++ ,
                METHOD ,
                uintBitNumber );

            byte byt8Bits = STACK | SOURCE;
            WizardWrx.BitMask32 b32 = new WizardWrx.BitMask32 ( byt8Bits );

            Console.WriteLine (
                MSG_TPL_ANTE ,
                new object [ ]
                {
                    rintTestNbr++ ,
                    byt8Bits ,
                    b32 ,
                    Environment.NewLine
                } );
            b32.BitOn ( BIT_6 );
            byt8Bits = ( byte ) b32;
            Console.WriteLine (
                MSG_TPL_POST ,
                byt8Bits ,
                b32 ,
                Environment.NewLine );

            Console.WriteLine (
                MSG_TPL_ANTE ,
                new object [ ]
                {
                    rintTestNbr++ ,
                    byt8Bits ,
                    b32 ,
                    Environment.NewLine
                } );
            b32.BitOff ( BIT_6 );
            byt8Bits = ( byte ) b32;
            Console.WriteLine (
                MSG_TPL_POST ,
                byt8Bits ,
                b32 ,
                Environment.NewLine );

            Console.WriteLine (
                MSG_DONE ,
                Environment.NewLine );
        }   // private static int TestSpecificBits
        }   // static Exercise method


        private static void RealWorldTests ( StreamWriter pswReport )
        {
            const string MSG_BEGIN = @"{0}Begin RealWorldTests{0}";
			const string MSG_DONE = @"{0}RealWorldTests Done{0}";
            const string MSG_FLAG_STACK = @"    New s_aenmStackTraceDisp value             = {0} ({1,3})";
            const string MSG_FLAG_SUBSYSTEM = @"        New s_aenmAppSubsystem value           = {0} ({1,3})";
            const string MSG_FLAG_EVENTLOGGING = @"            New s_aenmLoggingState value       = {0} ({1,3})";

            const string MSG_OPTION_FLAGS_DISP = @"                Test Case {0,3} OptionFlags {1,3} = {2,3}";
            const string MSG_OPTIONS_ANTE = @"Ante";
            const string MSG_OPTIONS_POST = @"Post";

            const string REPORT_HEADINGS = "StackTraceDisposition\tOutputDestination\tEventLogging\tInitialFlags\tFinalFlags";
            const string REPORT_DETAIL_LINE = "{0,3}\t{1,3}\t{2,3}\t{3,3}\t{4,3}";

            Console.WriteLine (
                MSG_BEGIN ,
                Environment.NewLine );

            pswReport.WriteLine ( REPORT_HEADINGS );

            OutputOptions enmFlags = OutputOptions.Method | OutputOptions.Source;
            uint uintCase = StandardConstants.ZERO;

            foreach ( OutputOptions enmStackDisp in s_aenmStackTraceDisp )
            {   // Stack tracing is either ON or OFF.
                Console.WriteLine (
                    MSG_FLAG_STACK ,
                    enmStackDisp ,
                    ( byte ) enmStackDisp );

                foreach ( OutputOptions enmSubsystem in s_aenmAppSubsystem )
                {   // ExceptionLogger.Subsystem collapses to one of only three values.
                    Console.WriteLine (
                        MSG_FLAG_SUBSYSTEM ,
                        enmSubsystem ,
                        ( byte ) enmSubsystem );

                    foreach ( OutputOptions enmEventLogUsage in s_aenmLoggingState )
                    {   // Event logging is either ON or OFF.
                        Console.WriteLine (
                            MSG_FLAG_EVENTLOGGING ,
                            enmEventLogUsage ,
                            ( byte ) enmEventLogUsage );

                        //  ----------------------------------------------------
                        //  From this point forward, the code is identical with
                        //  the test code that brought this matter to my
                        //  attention.
                        //  ----------------------------------------------------

                        Console.WriteLine (
                            MSG_OPTION_FLAGS_DISP ,
                            ++uintCase ,
                            MSG_OPTIONS_ANTE ,
                            enmFlags );

                        OutputOptions enmInitialFlags = enmFlags;
                        BitArray32 b32Flags = new BitArray32 ( ( UInt32 ) enmFlags );

                        if ( ( enmSubsystem & OutputOptions.StandardError ) == OutputOptions.StandardError )
                            b32Flags.BitOn ( ( int ) BitArray32.BitNumber ( ( UInt32 ) OutputOptions.StandardError ) );
                        else
                            b32Flags.BitOff ( ( int ) BitArray32.BitNumber ( ( UInt32 ) OutputOptions.StandardError ) );

                        if ( ( enmStackDisp & OutputOptions.Stack ) == OutputOptions.Stack )
                            b32Flags.BitOn ( ( int ) BitArray32.BitNumber ( ( UInt32 ) OutputOptions.Stack ) );
                        else
                            b32Flags.BitOff ( ( int ) BitArray32.BitNumber ( ( UInt32 ) OutputOptions.Stack ) );

                        if ( ( enmEventLogUsage & OutputOptions.EventLog ) == OutputOptions.EventLog )
                            b32Flags.BitOn ( ( int ) BitArray32.BitNumber ( ( UInt32 ) OutputOptions.EventLog ) );
                        else
                            b32Flags.BitOff ( ( int ) BitArray32.BitNumber ( ( UInt32 ) OutputOptions.EventLog ) );

                        enmFlags = ( OutputOptions ) ( ( UInt32 ) b32Flags );

                        Console.WriteLine (
                            MSG_OPTION_FLAGS_DISP ,
                            uintCase ,
                            MSG_OPTIONS_POST ,
                            enmFlags );

                        pswReport.WriteLine (
                            REPORT_DETAIL_LINE ,
                            new object [ ]
                            {
                                ( byte ) enmStackDisp ,         // Token 0 = StackTraceDisposition
                                ( byte ) enmSubsystem ,         // Token 1 = OutputDestination
                                ( byte ) enmEventLogUsage ,     // Token 2 = EventLogging
                                ( byte ) enmInitialFlags ,      // Token 3 = InitialFlags
                                ( byte ) enmFlags               // Token 4 = FinalFlags
                            } );
                    }   // foreach ( OutputOptions enmStackDisp in s_aenmStackTraceDisp )
                }   // foreach ( OutputOptions enmSubsystem in s_aenmAppSubsystem )
            }   // foreach ( OutputOptions enmEventLogUsage in s_aenmLoggingState )

            Console.WriteLine (
                MSG_DONE ,
                Environment.NewLine );
        }   // private static void RealWorldTests