public void Add_With_Delimiter_Between_Numbers(string numbers)
        {
            // Assign
            var calc = new StringCalculator();

            // Arrange
            calc.Add(numbers);

            // Assert
            var expected = 3;

            Assert.AreEqual(expected, calc.answer);
        }
        public void Add_Pseudo_Unknown_Number_Of_Numbers(string numbers)
        {
            // Assign
            var calc = new StringCalculator();

            // Arrange
            calc.Add(numbers);

            // Assert
            var expected = numbers.Split(',').Sum((a) => int.Parse(a));

            Assert.AreEqual(expected, calc.answer);
        }
        public void Add_Newline_Between_Numbers(string numbers)
        {
            // Assign
            var calc = new StringCalculator();

            // Arrange
            calc.Add(numbers);

            // Assert
            var expected = numbers.Replace('\n', ',').Split(',').Sum((a) => int.Parse(a));

            Assert.AreEqual(expected, calc.answer);
        }
Exemplo n.º 4
0
        //method name, scenario under which testing, & expected outcome
        //public void UnitUnderTest_Scenario_ExpectedOutcome()
        public void Add_EmptyString_Returns_0()
        {
            //Arrange: initialize object and sets the value of the data
            //that is passed to the method under test
            StringCalculator calc = new StringCalculator();

            //Act: invokes the method under test ('Add' in StringCalculator)
            int expectedResult = 0;

            //this test started failing; see fix in
            //StringCalculator.cs
            int result = calc.Add("");

            //Assert: verifies that the action of the method under test behaves as expected
            Assert.AreEqual(expectedResult, result);
        }
Exemplo n.º 6
0
        public void Add_EmptyDelimiterIsRejected(string inpString)
        {
            var calculator = new StringCalculator();

            calculator.Add(inpString);
        }
Exemplo n.º 7
0
        public void Add_NullIsRejected()
        {
            var calculator = new StringCalculator();

            calculator.Add(null);
        }
Exemplo n.º 8
0
 public void Add_StringContainingSingleNumber_ReturnsTheNumberItself()
 {
     Assert.AreEqual(5, StringCalculator.Add("5"));
 }
Exemplo n.º 9
0
 public void Add_EmptyStringAsParam_ReturnsZero()
 {
     Assert.AreEqual(0, StringCalculator.Add(string.Empty));
 }
Exemplo n.º 10
0
        public int CalculateNumbers(string numbers)
        {
            int result = addCalculator.Add(numbers);

            return(result);
        }