public void AddEmptyReturn0()
        {
            //Act
            var result = _stringCalc.Add("");

            //Assert
            Assert.Equal(0, result);
        }
        public void return_zero_if_input_is_empty()
        {
            int expectedResult = 0;

            int result = stringCalculator.Add("");

            Assert.AreEqual(expectedResult, result);
        }
        private void ArrangeActAndAssert(string numbers, int expected)
        {
            IStringCalculator stringCalculator = GetStringCalculator();
            int result = stringCalculator.Add(numbers);

            Assert.AreEqual(expected, result);
        }
        public void Add_NegativeNumber_ThrowsException(string numbers, string negativeNumbersAreNotAllowed)
        {
            IStringCalculator stringCalculator = GetStringCalculator();
            TestDelegate      testDelegate     = () => stringCalculator.Add(numbers);
            var ex = Assert.Throws <ArgumentException>(testDelegate);

            Assert.AreEqual(negativeNumbersAreNotAllowed, ex.Message);
        }
Пример #5
0
        public void run()
        {
            bool userWantToExit = false;

            logger.Write("write scalc [your_entry] to use the calculator");
            while (!userWantToExit)
            {
                string inputstring = input.GetInput();
                if (inputstring.Equals("") || inputstring.Equals(" "))
                {
                    userWantToExit = true;
                }
                else
                {
                    string[] userInputParts = inputstring.Split(' ');
                    if (userInputParts[0] == "scalc")
                    {
                        stringCalculator.Add(userInputParts[1]);
                    }
                    logger.Write("another input please");
                }
            }
        }
Пример #6
0
        public void Add_EmptyString_ReturnZero()
        {
            var result = calculator.Add("");

            Assert.AreEqual(0, result);
        }
 private void DisplaySum(string numbers)
 {
     _console.WriteLine(string.Format("The result is {0}", _calculator.Add(numbers)));
 }
Пример #8
0
 public int Add(string values)
 {
     return(_calculator.Add(values));
 }
        public void AddMethodReturnsZeroForEmptyString()
        {
            int result = _stringCalculator.Add("");

            result.Should().Be(0);
        }