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

            var testee = new SwitchActivity()
            {
                Value = new AnyVariable <int>()
                {
                    Value = 1
                },
                Cases = new Dictionary <object, IActivity>()
                {
                    { 1, new SuspendActivity()
                      {
                          Until = new TrueCondition()
                          {
                              Value = value
                          }
                      } }
                }
            };

            await testee.Start();

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

            value.SetValue <bool>(true);

            await testee.Start();

            Assert.AreEqual(ActivityStatus.Completed, testee.Status);
        }
Esempio n. 2
0
        public async Task Test___Method_Start___Status_Suspended_to_Completed()
        {
            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);

            value.SetValue <bool>(true);

            await testee.Start();

            Assert.AreEqual(ActivityStatus.Completed, testee.Status);
        }
Esempio n. 3
0
        public async Task Test___Method_Start___Status_Created___Condition_True()
        {
            var variable = new AnyVariable <bool>()
            {
                Value = true
            };
            var duration = new AnyVariable <int>()
            {
                Value = 1000
            };

            var testee = new WhileActivity()
            {
                Condition = new TrueCondition()
                {
                    Value = variable
                },
                Activity = new DelayActivity()
                {
                    Duration = duration
                }
            };

            var task = testee.Start();

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

            Thread.Sleep(3000);

            variable.SetValue(false);

            await task;

            Assert.AreEqual(ActivityStatus.Completed, testee.Status);
        }
Esempio n. 4
0
        public void Test___Method_SetValue___Generic_Class()
        {
            var testee = new AnyVariable <int>()
            {
                Value = 10
            };

            testee.SetValue(20);
            Assert.AreEqual(20, testee.GetValueAsObject());
        }
Esempio n. 5
0
        public async Task Test___Method_ToActivity___async()
        {
            var value = new AnyVariable <int>();

            var testee = new Func <CancellationToken, Task <bool> >(async(cancellationToken) =>
            {
                value.SetValue(10);
                return(await Task.FromResult(true));
            });

            await testee.ToActivity().Start();

            Assert.AreEqual(10, value.GetValue());
        }
Esempio n. 6
0
        public async Task Test___Method_ToActivity___sync()
        {
            var value = new AnyVariable <int>();

            var testee = new Func <bool>(() =>
            {
                value.SetValue(10);
                return(true);
            });

            await testee.ToActivity().Start();

            Assert.AreEqual(10, value.GetValue());
        }
Esempio n. 7
0
        public async Task Test___Method_Start___Status_Suspended_to_Completed()
        {
            var duration = new AnyVariable <int>()
            {
                Value = 1000
            };
            var value = new AnyVariable <bool>()
            {
                Value = false
            };

            var testee = new ParallelActivity()
            {
                Activities = new List <IActivity>()
                {
                    new DelayActivity()
                    {
                        Duration = duration
                    },
                    new SuspendActivity()
                    {
                        Until = new TrueCondition()
                        {
                            Value = value
                        }
                    }
                }
            };

            await testee.Start();

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

            value.SetValue <bool>(true);

            await testee.Start();

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