Esempio n. 1
0
        public void TestWorkstepErrorHandlingSimple()
        {
            //IWorkContext context = new WorkContext(null, TestEnvironment.Client);
            _workContext.Logger.LogDebug("starting...");
            var w = new WorkstepBase <int, string>(
                // step body
                delegate(int input)
            {
                if (input < 0)
                {
                    throw new ArgumentOutOfRangeException("input", input, "Must be > 0");
                }
                return(input.ToString(CultureInfo.InvariantCulture));
            },
                // exception handler
                (input, e) => e.GetType().Name);

            w.Initialise(_workContext);
            string noFailResult = w.Execute(1).Result;

            Assert.AreEqual("1", noFailResult);
            string failedResult = w.Execute(-1).Result;

            Assert.AreEqual("ArgumentOutOfRangeException", failedResult);
            _workContext.Logger.LogDebug("complete.");
        }
Esempio n. 2
0
        public void TestWorkstepDelegation()
        {
            // defines and executes a single workstep via delegate methods
            var w = new WorkstepBase <T1, T2>(
                delegate(T1 input)
            {
                T2 result;
                result.b = input.a;
                return(result);
            }, null);

            w.Initialise(_workContext);
            var t1 = new T1 {
                a = 42
            };
            var t2 = w.Execute(t1).Result;

            Assert.AreEqual(42, t2.b);
        }