public void NumberOfOthers_WhenMultipleSameSymbol() { // arrange string test = "!!!!!!"; int expected = 6; StringBreakout.NumberOfOthers(test); int actual = StringBreakout.NumberOthers; Assert.AreEqual(expected, actual); }
public void NumberOfOthers_WhenNoOthers() { // arrange string test = "123786ABCasd"; int expected = 0; StringBreakout.NumberOfOthers(test); int actual = StringBreakout.NumberOthers; Assert.AreEqual(expected, actual); }
public void NumberOfOthers_WhenValidInPut() { // arrange string test = "!@#ABC123$%^"; int expected = 6; StringBreakout.NumberOfOthers(test); int actual = StringBreakout.NumberOthers; Assert.AreEqual(expected, actual); }
public static void Main(string[] args) { int extractedNumberFromString; Console.WriteLine("Function Client\n===============\n"); if (args.Length == 0) { Console.WriteLine("Usage: FunctionTest <test string> "); return; } for (int i = 0; i < args.Length; i++) { // analyze the incoming "test string" to determine what types of // characters are present ... // // first - how many digits are found within the string ... Console.WriteLine("The Digit Count for String [{0}] is [{1}]", args[i], StringBreakout.NumberOfDigits(args[i])); // // next - how many alphabetic characters are found within the string ... Console.WriteLine("The Alpha Count for String [{0}] is [{1}]", args[i], StringBreakout.NumberOfAlphas(args[i])); // // lastly - determine the number of non-digit / non-alpha characters Console.WriteLine("The Other Count for String [{0}] is [{1}]", args[i], StringBreakout.NumberOfOthers(args[i])); // next function to call is to extract the number(s) from the string and use it to determine // its factorial ! // // ************************************************************************************************* // the code below assumes that the argv[i] string *only* contains digits. I want you to write // another class method in the StringBreakout class to detect and extract the numbers hidden in // the incoming string and use that number in the factorial calculation // for example, if the incoming string is Char1i3 <<< yes there is a "1" and "3" in that string // then the method you write would find the "1" and the "3" and return the value // 13 // this new method should look like : // int FindAndExtractDigits(string theString) // ************************************************************************************************* try { extractedNumberFromString = Int32.Parse(args[i]); Console.WriteLine(" >>> {0}! = {1}", extractedNumberFromString, Factorial.Calc(extractedNumberFromString)); } catch (FormatException e) { Console.WriteLine(" >>> String contained no digits ..."); } } }
public void NooDigitAlphas() { Assert.AreEqual(StringBreakout.NumberOfOthers(mix), mix.Length - mixAlphaLength - mixDigitLength); }
public void NooSingleExtraction() { Assert.AreEqual(StringBreakout.NumberOfOthers(alphas + "?"), 1); }
public void NooBlankString() { Assert.AreEqual(StringBreakout.NumberOfOthers(""), 0); }
public void NooNullString() { StringBreakout.NumberOfOthers((string)null); }