Пример #1
0
        public void Original_TestCase_Using_RunningStats()
        {
            RunningStatsCalc calc = new RunningStatsCalc();

            MathDto m1 = new MathDto()
            {
                Average           = 4,
                StandardDeviation = 0.0
            };

            m1.Should().BeEquivalentTo(calc.Calculate(4));

            MathDto m2 = new MathDto()
            {
                Average           = 5.5,
                StandardDeviation = 1.5
            };

            m2.Should().BeEquivalentTo(calc.Calculate(7));

            MathDto m3 = new MathDto()
            {
                Average           = 5.667,
                StandardDeviation = 1.247
            };

            m3.Should().BeEquivalentTo(calc.Calculate(6));

            AESSecure secure = new AESSecure();
            var       c      = calc.Calculate(9);

            secure.Decrypt(secure.Encrypt(c.Average.ToString())).Should().BeEquivalentTo("6.5");
            secure.Decrypt(secure.Encrypt(c.StandardDeviation.ToString())).Should().BeEquivalentTo("1.803");

            MathDto m4 = new MathDto()
            {
                Average           = 5.4,
                StandardDeviation = 2.728
            };

            m4.Should().BeEquivalentTo(calc.Calculate(1));
        }
Пример #2
0
        public void Test_VeryLargeDataSet()
        {
            var lines             = File.ReadLines("sampleSetLarge.txt");
            RunningStatsCalc calc = new RunningStatsCalc();

            Parallel.ForEach(lines, (line) =>
            {
                MathDto m = calc.Calculate(long.Parse(line));
                _output.WriteLine("Mean: {0} SD: {1}", m.Average, m.StandardDeviation);
            }
                             );
        }