public void WfConstructor()
        {
            var workflow = new Workflow();

            workflow.Save();
            var metadata = new WorkflowMetadata(workflow);
        }
Esempio n. 2
0
        public WorkflowMetadata Create(Workflow wf)
        {
            var result = new WorkflowMetadata(wf);

            var nextActivity = wf.Cast <WfActivity>().CreateWindowsActivity();

            nextActivity.Validate(result);

            return(result);
        }
        public void CompileWorkflows()
        {
            var wfs = Entity.GetInstancesOfType <Workflow>();

            var errors = new List <string>();

            Console.Write("Compiling");

            foreach (var wf in wfs)
            {
                Console.Write(".");
                var metadata = new WorkflowMetadata(wf);

                if (metadata.HasViolations)
                {
                    errors.Add(wf.Name);
                    Console.WriteLine("\nErrors in '{0}':{1}\n", wf.Name, string.Join("\n\t", metadata.ValidationMessages));
                }
            }

            Assert.That(errors, Is.Empty, "All workflows should be valid.");
        }
        public void TestInputVarNotSet()
        {
            using (new WorkflowRunContext {
                RunTriggersInCurrentThread = true
            })
            {
                var wf = new Workflow();

                wf.AddDefaultExitPoint();

                var forEach1 = new ForEachResource
                {
                    Name = "foreach1" + DateTime.Now
                };
                var forEach1As = forEach1.As <WfActivity>();

                wf.FirstActivity = forEach1As;
                wf.ContainedActivities.Add(forEach1As);

                var loopExitPoint = Entity.Get <ExitPoint>(ForeachImplementation.LoopExitPointAlias);

                ActivityTestHelper.AddTransition(wf, forEach1As, forEach1As, loopExitPoint);
                ActivityTestHelper.AddTermination(wf, forEach1As);
                //ActivityHelper.AddMissingExpressionParametersToWorkflow(wf);

                wf.Save();
                ToDelete.Add(wf.Id);

                ActivityImplementationBase nextActivity = forEach1As.Cast <WfActivity>().CreateWindowsActivity();

                var metaData = new WorkflowMetadata();
                nextActivity.Validate(metaData);

                Assert.IsTrue(metaData.ValidationMessages.Count() == 1, "There is only one validation message");
                Assert.IsTrue(metaData.ValidationMessages.First().StartsWith("Mandatory argument"), "Validation is 'Mandatory argument'");
            }
        }
Esempio n. 5
0
        public void SecondaryIdentityIsTriggeringWhenWfIsRunAsOwner()
        {
            var triggerer = new UserAccount();

            triggerer.Name = "foo" + Guid.NewGuid().ToString();
            triggerer.Save();

            var owner = new UserAccount();

            owner.Name = "foo2" + Guid.NewGuid().ToString();
            owner.Save();

            var wf = new Workflow()
            {
                SecurityOwner = owner, WorkflowRunAsOwner = true
            };

            wf.Save();

            using (var setUser = new SetUser(triggerer))
            {
                using (new SecurityBypassContext())
                {
                    var metadata = new WorkflowMetadata(wf);

                    var run      = new WorkflowRunDeferred(new Workflow());
                    var runState = DefaultRunStateFactory.Singleton.CreateRunState(metadata, run);
                    //var runState = new TestRunState(metadata, run);

                    Assert.That(runState.EffectiveSecurityContext.Identity, Is.Not.Null);
                    Assert.That(runState.EffectiveSecurityContext.Identity.Id, Is.EqualTo(owner.Id));
                    Assert.That(runState.EffectiveSecurityContext.SecondaryIdentity, Is.Not.Null);
                    Assert.That(runState.EffectiveSecurityContext.SecondaryIdentity.Id, Is.EqualTo(triggerer.Id));
                }
            }
        }
        public void CompileWorkflow(TenantInfo tenant, long workflowId, string workflowName)
        {
            using (tenant.GetTenantAdminContext( ))
                using (new MemoryGuard(2 * TenantHealthHelpers.OneGb, ClearSelectedCaches))
                    using (new MemoryGuard(3 * TenantHealthHelpers.OneGb, TenantHealthHelpers.ClearAllCaches))
                        using (new MemoryLogger(new KeyValuePair <string, object>("Tenant", tenant.TenantName), new KeyValuePair <string, object>("Workflow Id", workflowId)))
                        {
                            // Load workflow
                            Workflow workflow = Factory.EntityRepository.Get <Workflow>(workflowId);
                            Assert.That(workflow, Is.Not.Null, "Workflow entity not null");

                            // Compile workflow
                            var metadata = new WorkflowMetadata(workflow);

                            // Check for validation errors
                            string messages = null;
                            if (metadata.ValidationMessages != null)
                            {
                                messages = string.Join("\r\n", metadata.ValidationMessages);
                            }

                            Assert.That(metadata.HasViolations, Is.False, messages);
                        }
        }
Esempio n. 7
0
 public IRunState CreateRunState(WorkflowMetadata metaData, WorkflowRun workflowRun)
 {
     return(new TestRunState(metaData, workflowRun));
 }
Esempio n. 8
0
 public TestRunState(WorkflowMetadata metaData, WorkflowRun workflowRun)
     : base(metaData, workflowRun, new RequestContextData(RequestContext.GetContext()))
 {
 }
 public void DefaultConstructor()
 {
     var metadata = new WorkflowMetadata();
 }
Esempio n. 10
0
 /// <summary>
 /// Construcor
 /// </summary>
 public Workflow() : base()
 {
     ContentType = ContentType.Workflow;
     Metadata    = new WorkflowMetadata();
     Content     = new WorkflowContent();
 }