Exemplo n.º 1
0
        public void given_timespan_in_s_chars_per_sec_accurate_for_whole_numbers(string text, int numSeconds, int expected)
        {
            var time = new TimeSpan(0, 0, 0, numSeconds);
            var data = new AnalyticData()
            {
                Elapsed = time, TextEntered = text
            };
            var speed = new Speed(data);

            speed.Compute();
            Assert.That(speed.CharsPerSecond, Is.EqualTo(expected), string.Format("text {0} in {1}s should be {2}", text, numSeconds, expected));
        }
Exemplo n.º 2
0
        public void given_timespan_in_s_wpm_accurate_for_fractions(int numSeconds, string text, double expected)
        {
            var time = new TimeSpan(0, 0, 0, numSeconds);
            var data = new AnalyticData()
            {
                Elapsed = time, TextEntered = text
            };
            var speed = new Speed(data);

            speed.Compute();

            Assert.That(speed.WordsPerMinute, Is.EqualTo(expected), string.Format("text {0} in {1}s should be {2}", text, numSeconds, expected));
        }
Exemplo n.º 3
0
        public void given_timespan_in_s_chars_per_sec_accurate_for_fractions()
        {
            var time = new TimeSpan(0, 0, 0, 6);
            var data = new AnalyticData()
            {
                Elapsed = time, TextEntered = "ab"
            };
            var speed = new Speed(data);

            speed.Compute();

            double notRoundedExpected = (double)2 / 6;

            Assert.That(speed.CharsPerSecond, Is.Not.EqualTo(notRoundedExpected));

            double roundedExpected = Math.Round((double)2 / 6, Constants.PRECISION_FOR_DECIMALS);

            Assert.That(speed.CharsPerSecond, Is.EqualTo(roundedExpected));
        }