Esempio n. 1
0
        public void IgnoreValuesGreaterThan1000ReturnsSum()
        {
            //Arrange
            Calculator calc = new Calculator();
            string input = "10,20,\n30,1000,1001";
            //Act
            double answer = calc.Sum(input);

            //Assert
            Assert.AreEqual(1060.0, answer, 0.0001);
        }
Esempio n. 2
0
        public void DivideNumbersReturnSum()
        {
            //Arrange
            Calculator calc = new Calculator();

            //Act
            double sum = calc.Div(10.0, 2.0);

            //Assert
            Assert.AreEqual(5.0, sum, 0.01);
        }
Esempio n. 3
0
        public void EmptyStringReturnsSumZero()
        {
            //Arrange
            Calculator calc = new Calculator();
            string input = "";
            //Act
            double answer = calc.Sum(input);

            //Assert
            Assert.AreEqual(0.0, answer,0.0001);
        }
Esempio n. 4
0
        public void AddArrayOfNumbersReturnSum()
        {
            //Arrange
            Calculator calc = new Calculator();
            double[] numbers = new double[5] { 1, 2, 3, 4, 5 };
            //Act
            double sum = calc.Add(numbers);

            //Assert
            Assert.AreEqual(15.0, sum, 0.01);
        }
Esempio n. 5
0
        public void AddNumbersReturnSum()
        {
            //Arrange
            Calculator calc = new Calculator();

            //Act
            double sum = calc.Add(10.0, 10.0);

            //Assert
            Assert.AreEqual(20.0, sum, 0.01);  //3:e parameter är Deltavärde då man inte kan jämföra för exakt lika med noll med flyttal.
        }
Esempio n. 6
0
        public void NegativeNumbersCastsException()
        {
            //Arrange
            Calculator calc = new Calculator();

            string input = "10\n-20,30";
            //Act
            double answer = calc.Sum(input);
        }
Esempio n. 7
0
        public void MultiplyNumbersReturnSum()
        {
            //Arrange
            Calculator calc = new Calculator();

            //Act
            double sum = calc.Mul(10.0, 10.0);

            //Assert
            Assert.AreEqual(100.0, sum, 0.01);
        }
Esempio n. 8
0
        public void TwoValuesWithNewLineStringReturnsSum()
        {
            //Arrange
            Calculator calc = new Calculator();
            string input = "10\n20";
            //Act
            double answer = calc.Sum(input);

            //Assert
            Assert.AreEqual(30.0, answer, 0.0001);
        }
Esempio n. 9
0
        public void TryDivideByZeroCastsException()
        {
            //Arrange
            Calculator calc = new Calculator();

            //Act
            double sum = calc.Div(10.0, 0.0);
        }
Esempio n. 10
0
        public void TestNumIsPositiveReturnsTrue()
        {
            //Arrange
            Calculator calc = new Calculator();
            //Act
            bool answer = calc.IsPositive(0.0);

            //Assert
            Assert.AreEqual(true, answer);
        }
Esempio n. 11
0
        public void TestNumIsNegativeReturnsFalse()
        {
            //Arrange
            Calculator calc = new Calculator();
            //Act
            bool answer = calc.IsPositive(-1.0);

            //Assert
            Assert.AreEqual(false, answer);
        }
Esempio n. 12
0
        public void SingleValueStringReturnsValue()
        {
            //Arrange
            Calculator calc = new Calculator();
            string input = "10";
            //Act
            double answer = calc.Sum(input);

            //Assert
            Assert.AreEqual(10.0, answer, 0.0001);
        }