Пример #1
0
        public void FindAndExtractDigits_ExtractMultipleNumbersWithSymbols()
        {
            // arrange
            string test     = "helloWo32r@#ld1";
            int    expected = 321;

            StringBreakout.FindAndExtractDigits(test);

            int actual = StringBreakout.ExtractNumbers;

            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        public void FindAndExtractDigits_ExtractSingleNumber()
        {
            // arrange
            string test     = "helloWorld1";
            int    expected = 1;

            StringBreakout.FindAndExtractDigits(test);

            int actual = StringBreakout.ExtractNumbers;

            Assert.AreEqual(expected, actual);
        }
Пример #3
0
        public void FindAndExtractDigits_WithOnlyNumbers()
        {
            // arrange
            string test     = "2013";
            int    expected = 2013;

            StringBreakout.FindAndExtractDigits(test);

            int actual = StringBreakout.ExtractNumbers;

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void FindAndExtractDigits_WhenNoInput()
        {
            // arrange
            string test     = "";
            int    expected = 0;

            StringBreakout.FindAndExtractDigits(test);

            int actual = StringBreakout.ExtractNumbers;

            Assert.AreEqual(expected, actual);
        }
Пример #5
0
    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 = StringBreakout.FindAndExtractDigits((string)null);
                Console.WriteLine("   >>> {0}! = {1}", extractedNumberFromString, Factorial.Calc(extractedNumberFromString));
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: {0}", e.Message);
            }
        }
    }
Пример #6
0
 public void FedOverFlow()
 {
     StringBreakout.FindAndExtractDigits("2147483648");
 }
Пример #7
0
 public void FedEachDigit()
 {
     Assert.AreEqual(StringBreakout.FindAndExtractDigits(digits), 123456789);
 }
Пример #8
0
 public void FedBlankString()
 {
     StringBreakout.FindAndExtractDigits("");
 }
Пример #9
0
 public void FedNullString()
 {
     StringBreakout.FindAndExtractDigits((string)null);
 }
Пример #10
0
 public void FedExtractionTest()
 {
     Assert.AreEqual(StringBreakout.FindAndExtractDigits("-as12?>.34LKd56!@#$78EIDKA9"), 123456789);
 }
Пример #11
0
 public void FedLeadingZeros()
 {
     Assert.AreEqual(StringBreakout.FindAndExtractDigits("00000000000000000000000" + digits), 123456789);
 }
Пример #12
0
 public void FedLowerBound()
 {
     Assert.AreEqual(StringBreakout.FindAndExtractDigits("0"), 0);
 }
Пример #13
0
 public void FedUpperBound()
 {
     Assert.AreEqual(StringBreakout.FindAndExtractDigits(int.MaxValue.ToString()), int.MaxValue);
 }