Ejemplo n.º 1
0
        public void StringTestLeftDollar(object parameter1, object parameter2, string expectedResult, bool throwsIllegalQuantity, bool throwsTypeMismatch)
        {
            var    mismatchTypeExceptionThrown = false;
            var    illegalQuantExceptionThrown = false;
            var    sut = new LeftDollar();
            string result;

            try
            {
                result = sut.Execute(new List <Accumulator> {
                    new Accumulator(parameter1), new Accumulator(parameter2)
                })
                         .ValueAsString();
                Assert.AreEqual(expectedResult, result);
            }
            catch (ClassicBasic.Interpreter.Exceptions.IllegalQuantityException)
            {
                illegalQuantExceptionThrown = true;
            }
            catch (ClassicBasic.Interpreter.Exceptions.TypeMismatchException)
            {
                mismatchTypeExceptionThrown = true;
            }

            Assert.AreEqual(throwsIllegalQuantity, illegalQuantExceptionThrown, "Illegal quant");
            Assert.AreEqual(throwsTypeMismatch, mismatchTypeExceptionThrown, "Mismatch");
        }
Ejemplo n.º 2
0
        public void StringTestLeftDollarNeedsTwoParameters(int count, bool throwsException)
        {
            var sut = new LeftDollar();

            var parameters = new List <Accumulator>
            {
                new Accumulator("ABCDEF"),
                new Accumulator(3.0),
                new Accumulator(2.0),
                new Accumulator(3.0)
            };

            var result = Test.Throws <SyntaxErrorException, Accumulator>(
                () => sut.Execute(parameters.Take(count).ToArray()),
                throwsException);
        }