Пример #1
0
        public void TestSimpleFork()
        {
            var eng = new FlowEngine();

            countGood = 0; countBad = 0;

            eng.Start(a => GoodStep(a))
            .ContinueWith(a => BadStep(a))
            .Where(new TupleList <Func <FlowStep, bool>, Action <FlowStep> >
            {
                { a => a.Result.ResultCode == FlowStepResultValues.Success, a => BadStep(a) },
                { a => a.Result.ResultCode == FlowStepResultValues.Failed, a => GoodStep(a) }
            })
            .IfAllSuccess(b => GoodStep(b));

            Assert.AreEqual(3, countGood);
            Assert.AreEqual(1, countBad);

            Assert.AreEqual(countGood + countBad, eng.Steps.Count);
            Assert.AreEqual(countGood, eng.Steps.Count - countBad);
            Assert.AreEqual(countBad, eng.Steps.Count - countGood);

            Assert.IsFalse(eng.AllWasGood());
            Assert.IsTrue(eng.SomethingWasWrong());
        }
Пример #2
0
        public void TestCountBad()
        {
            var eng = new FlowEngine();

            countGood = 0; countBad = 0;

            eng.Start(a => GoodStep(a))
            .ContinueWith(a => BadStep(a))
            .ContinueWith(a => GoodStep(a));

            Assert.AreEqual(countGood + countBad, eng.Steps.Count);
            Assert.AreEqual(countGood, eng.Steps.Count - countBad);
            Assert.AreEqual(countBad, eng.Steps.Count - countGood);

            Assert.IsFalse(eng.AllWasGood());
            Assert.IsTrue(eng.SomethingWasWrong());
        }
Пример #3
0
        public void TestSimpleCondition()
        {
            var eng = new FlowEngine();

            countGood = 0; countBad = 0;
            eng.Start(a => GoodStep(a))
            .ContinueWith(a => BadStep(a))
            .IfSuccess(a => GoodStep(a))     // This will never be executed
            .IfFailed(a => GoodStep(a));     // This will never be executed

            Assert.AreEqual(1, countGood);

            Assert.AreEqual(countGood + countBad, eng.Steps.Count);
            Assert.AreEqual(countGood, eng.Steps.Count - countBad);
            Assert.AreEqual(countBad, eng.Steps.Count - countGood);

            Assert.IsFalse(eng.AllWasGood());
            Assert.IsTrue(eng.SomethingWasWrong());
        }