Пример #1
0
        public void StringTestMidDollarNeedsTwoParameters(int count, bool throwsException)
        {
            var sut = new MidDollar();

            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);
        }
Пример #2
0
        public void StringTestMidDollar(
            object parameter1,
            object parameter2,
            object parameter3,
            string expectedResult,
            bool throwsIllegalQuantity,
            bool throwsTypeMismatch)
        {
            var    mismatchTypeExceptionThrown = false;
            var    illegalQuantExceptionThrown = false;
            var    sut = new MidDollar();
            string result;

            try
            {
                var parameters = new List <Accumulator> {
                    new Accumulator(parameter1), new Accumulator(parameter2)
                };
                if (parameter3 != null)
                {
                    parameters.Add(new Accumulator(parameter3));
                }

                result = sut.Execute(parameters).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");
        }