public MtResult MtAdd(ScriptThread thread, object[] args)
        {
            var result  = new MtResult();
            var reducer = new AddReducer(result);

            reducer.Reduce(args);
            return(result);
        }
Esempio n. 2
0
        public void TypedReducerFallsbackWhenActionIsNotSupportedTest()
        {
            IReducer <int> reducer = new AddReducer();
            // Supported action
            var result = reducer.Apply(0, new Add(1));

            Assert.AreEqual(1, result);
            // Fallback
            result = reducer.Apply(10, new Subtract(2));
            Assert.AreEqual(10, result);
            result = reducer.Apply(2, new Multiply(10));
            Assert.AreEqual(2, result);
            result = reducer.Apply(10, new Divide(2));
            Assert.AreEqual(10, result);
        }