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); }
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); }