예제 #1
0
파일: Tests.cs 프로젝트: kahneraja/BREDemo
        public void workflow_nested_spec()
        {
            Animal animal = new Animal { Age = 1, Health = HealthStatus.Healthy, Type = AnimalType.Cow };
            var package = new IPackage() { Entity = animal };

            Workflow grandchildWorkflow = new Workflow();
            grandchildWorkflow.Workflows.Add(new Workflow() { Specification = "Processor.CowSpecification" });

            Workflow childworkflow = new Workflow();
            childworkflow.Workflows.Add(new Workflow() { Specification = "Processor.HealthySpecification" });
            childworkflow.Workflows.Add(grandchildWorkflow);

            Workflow parentWorkflow = new Workflow();
            parentWorkflow.Workflows.Add(new Workflow() { Specification = "Processor.HeavySpecification" });
            parentWorkflow.Workflows.Add(childworkflow);

            Workflow grandParentWorkflow = new Workflow();
            grandParentWorkflow.Workflows.Add(new Workflow() { Specification = "Processor.YoungSpecification" });
            grandParentWorkflow.Workflows.Add(parentWorkflow);

            var spec = new WorkflowSpecification();
            spec.Workflow = grandParentWorkflow;

            Outcome outcome = spec.IsSatisfiedBy(package);

            TraceWorkflow(parentWorkflow);

            Assert.IsFalse(outcome.Result);
        }
예제 #2
0
파일: Tests.cs 프로젝트: kahneraja/BREDemo
        public void workflow_single_spec()
        {
            Animal animal = new Animal { Age = 1, Health = HealthStatus.Healthy, Type = AnimalType.Cow };
            var package = new IPackage() { Entity = animal };

            Workflow parentWorkflow = new Workflow();

            Workflow childworkflow = new Workflow();
            childworkflow.Specification = "Processor.CowSpecification";
            childworkflow.Condition = "And";

            parentWorkflow.Workflows.Add(childworkflow);

            var spec = new WorkflowSpecification();
            spec.Workflow.Workflows.Add(parentWorkflow);

            Outcome outcome = spec.IsSatisfiedBy(package);

            TraceWorkflow(parentWorkflow);

            Assert.IsTrue(outcome.Result);
        }