Exemple #1
0
        public void ThrowsExceptionGivenNegative()
        {
            // Arrange
            var    sc    = new StringCalc();
            string input = "-1,5,-4";

            // Act
            Exception exception = Assert.Throws <ArgumentException>(() => sc.Add(input));
            string    output    = "Negatives not allowed: -1,-4";

            // Assert
            Assert.Equal(exception.Message, output);
        }
Exemple #2
0
        public void HandlesUserDefinedDelimeter()
        {
            // Arrange
            var    sc       = new StringCalc();
            int    expected = 27;
            string input    = "//;\n8;10;9";

            // Act
            int output = sc.Add(input);

            // Assert
            Assert.Equal(expected, output);
        }
Exemple #3
0
        public void EmptyStringReturns0()
        {
            // Arrange
            var    sc       = new StringCalc();
            int    expected = 0;
            string input    = "";

            // Act
            int output = sc.Add(input);

            // Assert
            Assert.Equal(expected, output);
        }
Exemple #4
0
        public void StringWithNewLineSplitReturnsSum()
        {
            // Arrange
            var    sc       = new StringCalc();
            int    expected = 27;
            string input    = "8,10\n9";

            // Act
            int output = sc.Add(input);

            // Assert
            Assert.Equal(expected, output);
        }
Exemple #5
0
        public void StringWithTwoNumReturnsSum()
        {
            // Arrange
            var    sc       = new StringCalc();
            int    expected = 19;
            string input    = "10,9";

            // Act
            int output = sc.Add(input);

            // Assert
            Assert.Equal(expected, output);
        }
Exemple #6
0
        public void StringWithOneNumReturnsNum()
        {
            // Arrange
            var    sc       = new StringCalc();
            int    expected = 5;
            string input    = "5";

            // Act
            int output = sc.Add(input);

            // Assert
            Assert.Equal(expected, output);
        }