Пример #1
0
        public void NumberOfAlphas_WhenMultipleSameLetter()
        {
            // arrange
            string test     = "AAAAAA";
            int    expected = 6;

            StringBreakout.NumberOfAlphas(test);

            int actual = StringBreakout.NumberAlphas;

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

            StringBreakout.NumberOfAlphas(test);

            int actual = StringBreakout.NumberAlphas;

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

            StringBreakout.NumberOfAlphas(test);

            int actual = StringBreakout.NumberAlphas;

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

            StringBreakout.NumberOfAlphas(test);

            int actual = StringBreakout.NumberAlphas;

            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 = Int32.Parse(args[i]);
                Console.WriteLine("   >>> {0}! = {1}", extractedNumberFromString, Factorial.Calc(extractedNumberFromString));
            }
            catch (FormatException e)
            {
                Console.WriteLine("   >>> String contained no digits ...");
            }
        }
    }
Пример #6
0
 public void NoaEachAlphas()
 {
     Assert.AreEqual(StringBreakout.NumberOfAlphas(alphas), alphas.Length);
 }
Пример #7
0
 public void NoASingleExtraction()
 {
     Assert.AreEqual(StringBreakout.NumberOfAlphas(digits + "A"), 1);
 }
Пример #8
0
 public void NoaBlankString()
 {
     Assert.AreEqual(StringBreakout.NumberOfAlphas(""), 0);
 }
Пример #9
0
 public void NoaNullString()
 {
     StringBreakout.NumberOfAlphas((string)null);
 }
Пример #10
0
 public void NoaMixCheck()
 {
     Assert.AreEqual(StringBreakout.NumberOfAlphas(mix), mixAlphaLength);
 }