Exemplo n.º 1
0
        public void ImplementsICruncherAutomator(CruncherAutomator cruncher)
        {
            // -- Arrange

            // -- Act

            // -- Assert
            Assert.IsAssignableFrom <ICruncherAutomator>(cruncher);
        }
Exemplo n.º 2
0
        public void ImplementsICruncherAutomator(CruncherAutomator cruncher)
        {
            // -- Arrange

            // -- Act

            // -- Assert
            Assert.IsAssignableFrom<ICruncherAutomator>(cruncher);
        }
Exemplo n.º 3
0
        public void GetResultThrowsInvalidCastExceptionWhenApplyIsNotCalled(CruncherAutomator automator)
        {
            // -- Arrange

            // -- Act
            var automator2 = automator.Process(new ParserResult("MULTIPLY", 4))
                .Process(new ParserResult("SUBTRACT", 5))
                .Process(new ParserResult("DIVIDE", 2))
                .Process(new ParserResult("ADD", 8));

            // -- Assert
            Assert.ThrowsAny<InvalidCastException>(() => automator2.GetResult());
        }
Exemplo n.º 4
0
        public void GetResultThrowsInvalidCastExceptionWhenApplyIsNotCalled(CruncherAutomator automator)
        {
            // -- Arrange

            // -- Act
            var automator2 = automator.Process(new ParserResult("MULTIPLY", 4))
                             .Process(new ParserResult("SUBTRACT", 5))
                             .Process(new ParserResult("DIVIDE", 2))
                             .Process(new ParserResult("ADD", 8));


            // -- Assert
            Assert.ThrowsAny <InvalidCastException>(() => automator2.GetResult());
        }
Exemplo n.º 5
0
        public void CalculatesASimpleEquation(
            string[] input,
            decimal expected,
            [Frozen] Mock <IFile> fileMock,
            [Frozen(Matching.ImplementedInterfaces)] FileParser parser,
            [Frozen(Matching.ImplementedInterfaces)] CruncherAutomator cruncher,
            CalculatorService calculator)
        {
            // -- Arrange
            fileMock.Setup(m => m.ReadAllLines(It.IsAny <string>())).Returns(input);

            // -- Act
            var actual = calculator.Process(@"C:\fakePath.input");

            // -- Assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 6
0
        public void CalculatesASimpleEquation(
            int applyValue,
            int multiplyValue,
            int subtractValue,
            int divideValue,
            int addValue,
            decimal expected,
            CruncherAutomator automator)
        {
            // -- Arrange

            // -- Act
            var actual = automator.Process(new ParserResult("MULTIPLY", multiplyValue))
                .Process(new ParserResult("SUBTRACT", subtractValue))
                .Process(new ParserResult("DIVIDE", divideValue))
                .Process(new ParserResult("ADD", addValue))
                .Process(new ParserResult("APPLY", applyValue))
                .GetResult();

            // -- Assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 7
0
        public void CalculatesASimpleEquation(
            int applyValue,
            int multiplyValue,
            int subtractValue,
            int divideValue,
            int addValue,
            decimal expected,
            CruncherAutomator automator)
        {
            // -- Arrange

            // -- Act
            var actual = automator.Process(new ParserResult("MULTIPLY", multiplyValue))
                         .Process(new ParserResult("SUBTRACT", subtractValue))
                         .Process(new ParserResult("DIVIDE", divideValue))
                         .Process(new ParserResult("ADD", addValue))
                         .Process(new ParserResult("APPLY", applyValue))
                         .GetResult();

            // -- Assert
            Assert.Equal(expected, actual);
        }