예제 #1
0
        public void EmptyParametherTest()
        {
            var calc = new StringCalculatorClass();

            var result = calc.StringCalculator("");

            Assert.AreEqual(0, result);
        }
예제 #2
0
        public void ManyParamethersTest()
        {
            var calc = new StringCalculatorClass();

            var result = calc.StringCalculator("1,2,3,4");

            Assert.AreEqual(10, result);
        }
예제 #3
0
        public void GivenAnEmptyStringReturnZero()
        {
            //Arrange
            var stringCalculator = new StringCalculatorClass();
            //Act
            var emptyString = stringCalculator.Calculate("");

            //Assert
            Assert.Equal(0, emptyString);
        }
예제 #4
0
        public void DissalowNegativeNumbers()
        {
            //Arrange
            var stringCalculator = new StringCalculatorClass();
            //Act
            var throws = Assert.Throws <ArgumentException>(() => stringCalculator.Calculate("1,-2,-3"));

            //Assert
            Assert.Equal("error: negatives not allowed", throws.Message);
        }
예제 #5
0
        public void ReturnsAdditionWhenANewLineSeparatorIsUsed()
        {
            //Arrange
            var stringCalculator = new StringCalculatorClass();
            //Act
            var newLineSperator = stringCalculator.Calculate("1\n2,3");

            //Assert
            Assert.Equal(6, newLineSperator);
        }
예제 #6
0
        public void AnyNumberOfNumbersReturnsThereAddition()
        {
            //Arrange
            var stringCalculator = new StringCalculatorClass();
            //Act
            var manyNumbers = stringCalculator.Calculate("1,2,3,4,5,6,7,8,9");

            //Assert
            Assert.Equal(45, manyNumbers);
        }
예제 #7
0
        public void TwoNumbersReturnThereAddition()
        {
            //Arrange
            var stringCalculator = new StringCalculatorClass();
            //Act
            var oneNumber = stringCalculator.Calculate("4,4");

            //Assert
            Assert.Equal(8, oneNumber);
        }
예제 #8
0
        public void GivenASingleNumberReturnNumber()
        {
            //Arrange
            var stringCalculator = new StringCalculatorClass();
            //Act
            var oneNumber = stringCalculator.Calculate("4");

            //Assert
            Assert.Equal(4, oneNumber);
        }