}; // static readonly FileInfoExtensionMethods.FileDetailsToShow [ ] s_aenmDetailsToShow internal static int Exercise ( ref int pintTestNumber ) { const string TEST_REPORT_PREAMBLE = @"{2}Testing ShowFileDetails extension method with FileDetailsToShow = {0} ({1}):"; const string TEST_REPORT_TEMPLATE_ABS = @" Case {0}: Information gathered based on absolute file name: "; const string TEST_REPORT_TEMPLATE_REL = @" Case {0}: Information gathered based on relative file name: "; NewClassTests_20140914.BeginTest ( System.Reflection.MethodBase.GetCurrentMethod ( ).Name , ref pintTestNumber , Program.BEGIN_TEST_TAKE_METHOD_NAME_AT_FACE_VALUE ); string strRootAssemblyDirectory = Program.s_smTheApp.AppRootAssemblyFileDirName; string strRelativeFileName = @"..\..\..\Test_Data\MD5_File_Digests.DOCX"; string strAbsoluteFileName = Path.Combine ( strRootAssemblyDirectory , strRelativeFileName ); Console.WriteLine ( @"strRootAssemblyDirectory = {0}" , strRootAssemblyDirectory ); Console.WriteLine ( @"strRelativeFileName = {0}" , strRelativeFileName ); Console.WriteLine ( @"strAbsoluteFileName = {0}" , strAbsoluteFileName ); // ---------------------------------------------------------------- // Since everything uses the same two FileInfo objects, they may as // well be hoisted above the For loop. // ---------------------------------------------------------------- FileInfo infoAbsolute1 = new FileInfo ( strAbsoluteFileName ); FileInfo infoAbsolute2 = new FileInfo ( infoAbsolute1.FullName ); for ( int intJ = ArrayInfo.ARRAY_FIRST_ELEMENT ; intJ < s_aenmDetailsToShow.Length ; intJ++ ) { Console.WriteLine ( TEST_REPORT_PREAMBLE , // Format Control String with 4 tokens ( int ) s_aenmDetailsToShow [ intJ ] , // Format Item 0: FileDetailsToShow = {0} ( s_aenmDetailsToShow [ intJ ] , // Format Item 1: ({1}): intJ == ArrayInfo.ARRAY_FIRST_ELEMENT // Format Item 2: {2}Testing ShowFileDetails ? Environment.NewLine // First iteration : SpecialStrings.EMPTY_STRING ); // Subsequent iterations Console.WriteLine ( infoAbsolute1.ShowFileDetails ( s_aenmDetailsToShow [ intJ ] , // FileDetailsToShow penmFileDetailsToShow = FileDetailsToShow.Everything string.Format ( // string pstrLabel = null TEST_REPORT_TEMPLATE_REL , // Format Control String with 1 token ArrayInfo.OrdinalFromIndex ( intJ ) ) , // Format Item 0: Case {0}: Information true , // bool pfPrefixWithNewline = false true ) ); // bool pfSuffixWithNewline = false Console.WriteLine ( infoAbsolute1.ShowFileDetails ( s_aenmDetailsToShow [ intJ ] , // FileDetailsToShow penmFileDetailsToShow = FileDetailsToShow.Everything string.Format ( // string pstrLabel = null TEST_REPORT_TEMPLATE_ABS , // Format Control String with 1 token ArrayInfo.OrdinalFromIndex ( intJ ) ) , // Format Item 0: Case {0}: Information false , // bool pfPrefixWithNewline = false true ) ); // bool pfSuffixWithNewline = false } // for ( int intJ = ArrayInfo.ARRAY_FIRST_ELEMENT ; intJ < s_aenmDetailsToShow.Length ; intJ++ ) return NewClassTests_20140914.TestDone ( MagicNumbers.ERROR_SUCCESS , pintTestNumber ); } // internal static int Exercise
internal static int Exercise ( ref int pintTestNumber ) { const int SCENARIO_COUNT = 3; NewClassTests_20140914.BeginTest ( nameof ( StringExtensions ) , ref pintTestNumber , Program.BEGIN_TEST_TAKE_METHOD_NAME_AT_FACE_VALUE ); int intInputCase = ListInfo.LIST_IS_EMPTY; int intOverallCase = ListInfo.LIST_IS_EMPTY; int intTotalTestCases = s_astrTestStrings.Length * SCENARIO_COUNT; WizardWrx.ConsoleStreams.MessageInColor micSuccessfulOutcomeMessage = new WizardWrx.ConsoleStreams.MessageInColor ( Properties.Settings.Default.SuccessfulOutcomeMessageColor.EnumFromString<ConsoleColor> ( ) , Properties.Settings.Default.SuccessfulOutcomeMessageBackgroundColor.EnumFromString<ConsoleColor> ( ) ); WizardWrx.ConsoleStreams.MessageInColor micUnsuccessfulOutcomeMessage = new WizardWrx.ConsoleStreams.MessageInColor ( WizardWrx.ConsoleStreams.ErrorMessagesInColor.FatalExceptionTextColor , WizardWrx.ConsoleStreams.ErrorMessagesInColor.FatalExceptionBackgroundColor ); for ( int intJ = ArrayInfo.ARRAY_FIRST_ELEMENT ; intJ < s_astrTestStrings.Length ; intJ++ ) { Console.WriteLine ( @" Input string test {0} of {1}: Input String Length = {2}, Input String:{4}{3}{4}" , new object [ ] { ++intInputCase , // Format Item 0: Input string test {0} s_astrTestStrings.Length , // Format Item 1: of {1}: s_astrTestStrings [ intJ ].InputString.Length , // Format Item 2: Input String Length = {2} s_astrTestStrings [ intJ ].InputString , // Format Item 3: (s_astrTestStrings [ intJ ].InputString):{4}{3} Environment.NewLine // Format Item 4 } ); string strFormattedForMac = s_astrTestStrings [ intJ ].InputString.OldMacLineEndings ( ); string strFormattedForUnix = s_astrTestStrings [ intJ ].InputString.UnixLineEndings ( ); string strFormattedForWindows = s_astrTestStrings [ intJ ].InputString.WindowsLineEndings ( ); intOverallCase = ReportTestOutcome ( intOverallCase , intTotalTestCases , intJ , nameof ( strFormattedForMac ) , strFormattedForMac , SpecialCharacters.CARRIAGE_RETURN ); intOverallCase = ReportTestOutcome ( intOverallCase , intTotalTestCases , intJ , nameof ( strFormattedForUnix ) , strFormattedForUnix , SpecialCharacters.LINEFEED ); intOverallCase = ReportTestOutcome ( intOverallCase , intTotalTestCases , intJ , nameof ( strFormattedForWindows ) , strFormattedForWindows , SpecialStrings.STRING_SPLIT_NEWLINE ); } // for ( int intK = ArrayInfo.ARRAY_FIRST_ELEMENT ; intK < s_astrTestStrings.Length ; intK++ ) Console.WriteLine ( @"{1} Test summary: Successful Outcome Count = {0}" , s_intGoodOutcomes , Environment.NewLine ); Console.WriteLine ( @" Unsuccessful Outcome Count = {0}{1}" , s_intBadOutcomes , Environment.NewLine ); if ( s_intBadOutcomes == ListInfo.LIST_IS_EMPTY ) { micSuccessfulOutcomeMessage.WriteLine ( @" A-OK!" ); } // TRUE (antiicpated outcome) block, if ( s_intBadOutcomes == ListInfo.LIST_IS_EMPTY ) else { micUnsuccessfulOutcomeMessage.WriteLine ( @" YIKES!" ); } // FALSE (unantiicpated outcome) block, if ( s_intBadOutcomes == ListInfo.LIST_IS_EMPTY ) return NewClassTests_20140914.TestDone ( MagicNumbers.ERROR_SUCCESS , pintTestNumber ); } // internal static int Exercise