Exemplo n.º 1
0
        public async Task Test___Method_Start___Status_Suspended_to_Suspended()
        {
            var value = new AnyVariable <bool>()
            {
                Value = false
            };

            var testee = new IfActivity()
            {
                Condition = new TrueCondition(),
                Then      = new SuspendActivity()
                {
                    Until = new TrueCondition()
                    {
                        Value = value
                    }
                }
            };

            await testee.Start();

            Assert.AreEqual(ActivityStatus.Suspended, testee.Status);

            await testee.Start();

            Assert.AreEqual(ActivityStatus.Suspended, testee.Status);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Get([FromQuery(Name = "condition")] bool condition = true)  // false: Not Found
        {
            var actionResult = new AnyVariable <IActionResult>();

            var activity = new IfActivity()
            {
                Condition = new TrueCondition()
                {
                    Value = new AnyVariable <bool>()
                    {
                        Value = condition
                    }
                },
                Then = new AssignActivity()
                {
                    To    = actionResult,
                    Value = new OkObjectResultVariable()
                    {
                        Value = new AnyVariable()
                        {
                            Value = "Hello World!"
                        }
                    }
                },
                Else = new AssignActivity()
                {
                    To    = actionResult,
                    Value = new NotFoundResultVariable()
                }
            };

            await activity.Start();

            return(actionResult.GetValue());
        }
Exemplo n.º 3
0
        public async Task Test___Method_Start___Status_Created___Else_Completed()
        {
            var to = new AnyVariable <int>()
            {
                Value = 0
            };

            var testee = new IfActivity()
            {
                Condition = new FalseCondition(),
                Then      = new AssignActivity()
                {
                    To = to, Value = new AnyVariable <int>()
                    {
                        Value = 1
                    }
                },
                Else = new AssignActivity()
                {
                    To = to, Value = new AnyVariable <int>()
                    {
                        Value = 2
                    }
                }
            };

            await testee.Start();

            Assert.AreEqual(ActivityStatus.Completed, testee.Status);
            Assert.AreEqual(2, to.GetValueAsObject());
        }
Exemplo n.º 4
0
        public async Task Test___Method_Start___Status_Created___Else_Suspended()
        {
            var testee = new IfActivity()
            {
                Condition = new FalseCondition(),
                Then      = new NullActivity(),
                Else      = new SuspendActivity()
                {
                    Until = new FalseCondition()
                }
            };

            await testee.Start();

            Assert.AreEqual(ActivityStatus.Suspended, testee.Status);
        }
Exemplo n.º 5
0
        public async Task Test___Method_Stop___Status_Suspended()
        {
            var testee = new IfActivity()
            {
                Condition = new TrueCondition(),
                Then      = new SuspendActivity()
                {
                    Until = new FalseCondition()
                }
            };

            await testee.Start();

            Assert.AreEqual(ActivityStatus.Suspended, testee.Status);

            testee.Stop();

            Assert.AreEqual(ActivityStatus.Stopped, testee.Status);
        }
Exemplo n.º 6
0
        public async Task Test___Method_Stop___Status_Executing()
        {
            var testee = new IfActivity()
            {
                Condition = new TrueCondition(),
                Then      = new DelayActivity()
                {
                    Duration = new AnyVariable <int>()
                    {
                        Value = 1000
                    }
                }
            };

            var task = testee.Start();

            Assert.AreEqual(ActivityStatus.Executing, testee.Status);

            testee.Stop();

            await task;

            Assert.AreEqual(ActivityStatus.Stopped, testee.Status);
        }