コード例 #1
0
        /// <summary>
        /// Determines which of the three names were written faster
        /// </summary>
        ///
        public static void FastestOfThreeName()
        {
            Stopwatch crono = new Stopwatch();

            Console.WriteLine("Type your name three times");

            crono.Start();
            string firstName = Console.ReadLine();

            crono.Stop();
            long firstTimeName = crono.ElapsedMilliseconds;

            crono.Restart();

            crono.Start();
            string secondName = Console.ReadLine();

            crono.Stop();
            long secondTimeName = crono.ElapsedMilliseconds;

            crono.Restart();

            crono.Start();
            string thirdName = Console.ReadLine();

            crono.Stop();
            long thirdTimeName = crono.ElapsedMilliseconds;

            crono.Restart();

            FastNameType fastestName = FastName(firstName, secondName, thirdName, firstTimeName, secondTimeName, thirdTimeName);

            if (fastestName == FastNameType.FIRST_NAME_FAST)
            {
                Console.WriteLine("You wrote the first name fastest");
            }
            else if (fastestName == FastNameType.SECOND_NAME_FAST)
            {
                Console.WriteLine("You wrote the second name fastest");
            }
            else if (fastestName == FastNameType.THIRD_NAME_FAST)
            {
                Console.WriteLine("You wrote the third name fastest");
            }
            else
            {
                throw new ArgumentException("Unknown name order");
            }
        }
コード例 #2
0
        public void WorksForFastFirstSecondThirdNameEqual()
        {
            FastNameType firstThirdName = Week3.FastName("tuti", "tuti", "tuti", 1, 1, 1);

            Assert.AreEqual(firstThirdName, FastNameType.FIRST_NAME_FAST);
        }
コード例 #3
0
        public void WorksForFastFirstSecondNameEqual()
        {
            FastNameType thirdName = Week3.FastName("tuti", "tuti", "tuti", 3, 3, 9);

            Assert.AreEqual(thirdName, FastNameType.FIRST_NAME_FAST);
        }
コード例 #4
0
        public void WorksForFastThirdName()
        {
            FastNameType thirdName = Week3.FastName("tuti", "tuti", "tuti", 8, 9, 3);

            Assert.AreEqual(thirdName, FastNameType.THIRD_NAME_FAST);
        }
コード例 #5
0
        public void WorksForFastSecondName()
        {
            FastNameType secondName = Week3.FastName("made", "made", "made", 7, 4, 8);

            Assert.AreEqual(secondName, FastNameType.SECOND_NAME_FAST);
        }
コード例 #6
0
        public void WorksForFastFirstName()
        {
            FastNameType firstName = Week3.FastName("pepe", "pepe", "pepe", 1, 2, 2);

            Assert.AreEqual(firstName, FastNameType.FIRST_NAME_FAST);
        }
コード例 #7
0
        public void WorksForFastSecondThirdNameEqual()
        {
            FastNameType thirdName = Week3.FastName("tuti", "tuti", "tuti", 8, 3, 3);

            Assert.AreEqual(thirdName, FastNameType.SECOND_NAME_FAST);
        }