示例#1
0
        public void TypingStatsConstructorTest()
        {
            var target = new TypingStats_Accessor();

            Assert.IsNotNull(target);
            Assert.IsNotNull(target.stopWatch);
        }
示例#2
0
        public void GetAcuracyTest2()
        {
            var target = new TypingStats_Accessor {
                ErrorCount = 0, KeyCount = 12
            };
            const int expected = 100;
            int       actual   = target.GetAccuracy();

            Assert.AreEqual(expected, actual);
        }
示例#3
0
        public void StartTest()
        {
            var target = new TypingStats_Accessor();

            target.Start();
            Assert.AreEqual(0, target.KeyCount);
            Assert.AreEqual(0, target.ErrorCount);
            Assert.AreEqual(100, target.GetAccuracy());
            Assert.AreEqual(0, target.GetAverageWpm());
        }
示例#4
0
        public void StopTest()
        {
            var target = new TypingStats_Accessor();

            target.Start();
            target.Stop();
            const bool expected = false;
            bool       actual   = target.stopWatch.IsRunning;

            Assert.AreEqual(expected, actual);
        }
示例#5
0
        public void GetAverageWpmTest()
        {
            var target = new TypingStats_Accessor();

            // Simulate 5 words per second == 300 wpm

            target.Start();
            target.KeyCount = 25;
            Thread.Sleep(1000);
            target.Stop();

            const int expected = 300;
            int       actual   = target.GetAverageWpm();

            Assert.IsTrue((expected - actual) < 5);
        }