Exemple #1
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());
        }
Exemple #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());
        }
Exemple #3
0
        public void Test___Method_Reset___Status_Stopped()
        {
            var to = new AnyVariable <int>()
            {
                Value = 0
            };

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

            testee.Stop();

            Assert.AreEqual(ActivityStatus.Stopped, testee.Status);
            Assert.AreEqual(0, to.GetValueAsObject());

            testee.Reset();

            Assert.AreEqual(ActivityStatus.Created, testee.Status);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
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);
        }