Ejemplo n.º 1
0
        public void ShouldCalculateNegativePercent()
        {
            // Given an array of integers, calculate which fraction of its elements are positive, which fraction of its elements are negative, and which fraction of its elements are zeroes, respectively.Print the decimal value of each fraction on a new line.
            int[] array = new[] { -1, 0, 1 };

            PlusMinus plusMinus = new PlusMinus(array);

            string result = plusMinus.PercentNegative();

            result.Should().Be("0.333333");
        }
Ejemplo n.º 2
0
        public void ShouldCalculateForZero()
        {
            // Given an array of integers, calculate which fraction of its elements are positive, which fraction of its elements are negative, and which fraction of its elements are zeroes, respectively.Print the decimal value of each fraction on a new line.
            int[] array = new[] { -4, 3, -9, 3, 4, 1 };

            PlusMinus plusMinus = new PlusMinus(array);

            string resultP = plusMinus.PercentPositive();
            string resultN = plusMinus.PercentNegative();
            string resultZ = plusMinus.PercentZero();


            Console.WriteLine(plusMinus.PercentPositive());
            Console.WriteLine(plusMinus.PercentNegative());
            Console.WriteLine(plusMinus.PercentZero());

            resultP.Should().Be("0.666667");
            resultN.Should().Be("0.333333");
            resultZ.Should().Be("0.000000");
        }