예제 #1
0
        public void addReturnsInt()
        {
            var stringCalculator = new stringCalculator();
            var add = stringCalculator.Add("0");

            Assert.IsInstanceOfType(add, typeof(int));
        }
예제 #2
0
        public void testMaxNumberEqual()
        {
            var       stringcalculator = new stringCalculator();
            var       add            = stringcalculator.Add("//|\n1000|1|1");
            const int expectedResult = 1002;

            Assert.AreEqual(expectedResult, add);
        }
예제 #3
0
        public void addTwoNumbers()
        {
            var       stringcalculator = new stringCalculator();
            var       add            = stringcalculator.Add("1,4");
            const int expectedResult = 5;

            Assert.AreEqual(expectedResult, add);
        }
예제 #4
0
        public void allowMultpleDelimiters()
        {
            var       stringcalculator = new stringCalculator();
            var       add            = stringcalculator.Add("//[*][%]\n1*2%3");
            const int expectedResult = 6;

            Assert.AreEqual(expectedResult, add);
        }
예제 #5
0
        public void anyLenghtDelimters()
        {
            var       stringcalculator = new stringCalculator();
            var       add            = stringcalculator.Add("//[***]\n1***2***3”");
            const int expectedResult = 6;

            Assert.AreEqual(expectedResult, add);
        }
예제 #6
0
        public void chaningDelimiters()
        {
            var stringcalculator = new stringCalculator();
            var add = stringcalculator.Add("//;\n10");

            const int expectedresult = 10;

            Assert.AreEqual(expectedresult, add);
        }
예제 #7
0
        public void addStringsWithDelimeters()
        {
            var stringcalculator = new stringCalculator();
            var add = stringcalculator.Add("1\n7");

            const int expectedResult = 8;

            Assert.AreEqual(expectedResult, add);
        }
예제 #8
0
        public void addWhitespace()
        {
            var stringcalculator = new stringCalculator();
            var add = stringcalculator.Add(new string(' ', 5));

            const int expectedResult = 0;

            Assert.AreEqual(expectedResult, add);
        }
예제 #9
0
        public void testingNegatives()
        {
            var negativeNumbers  = "-1|-2|-3";
            var stringcalculator = new stringCalculator();

            try
            {
                var add = stringcalculator.Add($"//|\n{negativeNumbers}");
            }
            catch (ArgumentException exceptionNegatives)
            {
                const string negativeMessage = "negatives not allowed";
                Assert.IsTrue(exceptionNegatives.Message.ToUpper().Contains(negativeNumbers.Replace("|", ",")));
            }
        }