コード例 #1
0
        /// <summary>
        /// Test for correct data
        /// </summary>
        internal void PositiveTestGetColor()
        {
            // Positive case 1
            int       pairNumber = 5;
            ColorPair testPair1  = ColorCodeRegistry.GetColorFromPairNumber(pairNumber);

            Console.WriteLine("[In]Pair Number: {0},[Out] Colors: {1}\n", pairNumber, testPair1);
            Debug.Assert(testPair1.MajorColor == Color.White);
            Debug.Assert(testPair1.MinorColor == Color.SlateGray);

            // Positive case 2
            pairNumber = 24;
            testPair1  = ColorCodeRegistry.GetColorFromPairNumber(pairNumber);
            Console.WriteLine("[In]Pair Number: {0},[Out] Colors: {1}\n", pairNumber, testPair1);
            Debug.Assert(testPair1.MajorColor == Color.Violet);
            Debug.Assert(testPair1.MinorColor == Color.Brown);
        }
コード例 #2
0
        /// <summary>
        /// Test for incorrect data
        /// </summary>
        private void NegativeTestGetColor()
        {
            // Negatice test case with wrong pair number as input to simulate error condition
            int  pairNumber            = 0;
            bool errorConditionHandled = false;

            try
            {
                ColorPair testPair1 = ColorCodeRegistry.GetColorFromPairNumber(pairNumber);
                Console.WriteLine("[In]Pair Number: {0},[Out] Colors: {1}\n", pairNumber, testPair1);
            }
            catch (Exception)
            {
                errorConditionHandled = true;
                Console.WriteLine("Invalid Pair Number : {0}, Error Condition handled\n", pairNumber);
            }
            Debug.Assert(errorConditionHandled);
        }
コード例 #3
0
        /// <summary>
        /// Test for incorrect data
        /// </summary>
        private void NegativeTestGetPair()
        {
            // negative test case with wrong color as input to simulate error condition
            bool      errorConditionHandled = false;
            ColorPair testPair2             = new ColorPair()
            {
                MajorColor = Color.Red, MinorColor = Color.Maroon
            };

            try
            {
                int pairNumber = ColorCodeRegistry.GetPairNumberFromColor(testPair2);
                Console.WriteLine("[In]Colors: {0}, [Out] PairNumber: {1}\n", testPair2, pairNumber);
            }
            catch (Exception)
            {
                errorConditionHandled = true;
                Console.WriteLine("Invalid Color : {0}, Error Condition handled\n", testPair2);
            }
            Debug.Assert(errorConditionHandled);
        }
コード例 #4
0
        /// <summary>
        /// Test for correct data
        /// </summary>
        private void PositiveTestGetPair()
        {
            // Positive case 1
            ColorPair testPair2 = new ColorPair()
            {
                MajorColor = Color.Yellow, MinorColor = Color.Blue
            };
            int pairNumber = ColorCodeRegistry.GetPairNumberFromColor(testPair2);

            Console.WriteLine("[In]Colors: {0}, [Out] PairNumber: {1}\n", testPair2, pairNumber);
            Debug.Assert(pairNumber == 16);

            // Positive case 2
            testPair2 = new ColorPair()
            {
                MajorColor = Color.Red, MinorColor = Color.Green
            };
            pairNumber = ColorCodeRegistry.GetPairNumberFromColor(testPair2);
            Console.WriteLine("[In]Colors: {0}, [Out] PairNumber: {1}\n", testPair2, pairNumber);
            Debug.Assert(pairNumber == 8);
        }
コード例 #5
0
        /// <summary>
        /// Print the table
        /// </summary>
        internal void PrintColorTable()
        {
            ColorCodeRegistry coder = new ColorCodeRegistry();

            Console.WriteLine(coder.ToString());
        }