Exemplo n.º 1
0
        public void TwoInputs_Test2()
        {
            var expectedResult = new List <int>()
            {
                4, -3
            };
            var mockParser = new Mock <IParser>();

            mockParser.Setup(x => x.Parse(It.IsAny <string>())).Returns(expectedResult);

            var calculator = new MarksStringCalculator(mockParser.Object);

            var result = calculator.Add("4,-3");

            Assert.AreEqual(1, result);
        }
Exemplo n.º 2
0
        public void AlotOfInputs()
        {
            var expectedResult = new List <int>()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
            };
            var mockParser = new Mock <IParser>();

            mockParser.Setup(x => x.Parse(It.IsAny <string>())).Returns(expectedResult);

            var calculator = new MarksStringCalculator(mockParser.Object);

            var result = calculator.Add("1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12");

            Assert.AreEqual(78, result);
        }
Exemplo n.º 3
0
        public void SingleInput()
        {
            var expectedResult = new List <int>()
            {
                20
            };
            var mockParser = new Mock <IParser>();

            mockParser.Setup(x => x.Parse(It.IsAny <string>())).Returns(expectedResult);

            var calculator = new MarksStringCalculator(mockParser.Object);

            var result = calculator.Add("20");

            Assert.AreEqual(20, result);
        }
Exemplo n.º 4
0
        public void GetCalculatedNumbers()
        {
            var expectedResult = new List <int>()
            {
                2, 0, 4, 0, 0, 6
            };
            var mockParser = new Mock <IParser>();

            mockParser.Setup(x => x.Parse(It.IsAny <string>())).Returns(expectedResult);

            var calculator = new MarksStringCalculator(mockParser.Object);

            calculator.Add("2,,4,rrrr,1001,6");
            var result = calculator.CalculationString;

            Assert.AreEqual("2+0+4+0+0+6", result);
        }