Exemplo n.º 1
0
        public void Test___Method_Stop___Status_Created()
        {
            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
                }
            };

            testee.Stop();

            Assert.AreEqual(ActivityStatus.Stopped, testee.Status);
        }
Exemplo n.º 2
0
        public async Task Test___Method_Start___Status_Created___Condition_False()
        {
            var variable = new AnyVariable <bool>()
            {
                Value = false
            };
            var duration = new AnyVariable <int>()
            {
                Value = 1000
            };

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

            await testee.Start();

            Assert.AreEqual(ActivityStatus.Completed, testee.Status);
        }
Exemplo 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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create task of while activity to execute condition for while loop.
        /// </summary>
        /// <returns></returns>
        public Task <ActivityResult> CreateWhileActivity()
        {
            Task <ActivityResult> task = null;

            try
            {
                WhileActivity whileActivity = new WhileActivity();
                whileActivity.ExecuteCondition += new EventHandler <ConditionalEventArgs>(ExecuteWhileCondition);
                return(whileActivity.ExecuteAsync());
            }
            catch (ArgumentNullException exception)
            {
                base.Exception = exception;
            }
            return(task);
        }
Exemplo n.º 5
0
        void Container1()
        {
            System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition();

            // <snippet180>
            // <snippet181>
            // <snippet182>
            this.WhileLoop       = new System.Workflow.Activities.WhileActivity();
            this.Parallel        = new System.Workflow.Activities.ParallelActivity();
            this.Sequence1       = new System.Workflow.Activities.SequenceActivity();
            this.Sequence2       = new System.Workflow.Activities.SequenceActivity();
            this.ConsoleMessage1 = new System.Workflow.Activities.CodeActivity();
            this.ConsoleMessage2 = new System.Workflow.Activities.CodeActivity();
            //
            // WhileLoop
            //
            this.WhileLoop.Activities.Add(this.Parallel);
            codecondition1.Condition += new System.EventHandler <System.Workflow.Activities.ConditionalEventArgs>(this.WhileCondition);
            this.WhileLoop.Condition  = codecondition1;
            this.WhileLoop.Name       = "WhileLoop";
            // </snippet182>
            //
            // Parallel
            //
            this.Parallel.Activities.Add(this.Sequence1);
            this.Parallel.Activities.Add(this.Sequence2);
            this.Parallel.Name = "Parallel";
            // </snippet181>
            //
            // Sequence1
            //
            this.Sequence1.Activities.Add(this.ConsoleMessage1);
            this.Sequence1.Name = "Sequence1";
            //
            // Sequence2
            //
            this.Sequence2.Activities.Add(this.ConsoleMessage2);
            this.Sequence2.Name = "Sequence2";
            // </snippet180>
        }
Exemplo n.º 6
0
        public SimpleWorkFlowDelay()
        {
            CanModifyActivities = true;
            CodeCondition codecondition1 = new CodeCondition();

            BackUpFile         = new CodeActivity();
            WhileFilesToBackup = new WhileActivity();
            DelaySystemReady   = new DelayActivity();

            BackUpFile.ExecuteCode += new EventHandler(BackUpFile_ExecuteCode);

            WhileFilesToBackup.Activities.Add(BackUpFile);
            codecondition1.Condition += new EventHandler <ConditionalEventArgs>(MoreFiles);

            WhileFilesToBackup.Condition = codecondition1;

            DelaySystemReady.TimeoutDuration = TimeSpan.Parse("00:00:02");

            Activities.Add(DelaySystemReady);
            Activities.Add(WhileFilesToBackup);
            Name = "SimpleWorkFlowDelay";
            CanModifyActivities = false;
        }