public void You_cannot_create_an_operation_with_an_input_value_without_specifying_an_input_property_with_the_proper_type(IEnumerable <string> input)
        {
            var resolver = new SimpleOperationResolver();
            var factory  = new FakeOperationBehaviorFactory();

            factory.OperationBehaviors.Add(new FakeOperationBehavior());
            var correctConfiguration = new FakeWorkflowConfiguration {
                Resolver = resolver
            }.WithBehaviorFactory(factory);
            var sut = new FakeOperation();

            sut.Initialize(correctConfiguration);

            Assert.Throws <ArgumentException>(() => sut.PublicCreate <SimpleTestPropertyInputOperation, IEnumerable <string> >(input));
        }
        public void Resolving_operations_creates_and_applies_behaviors_to_the_created_operations(WorkflowConfiguration configuration)
        {
            var sut     = new SimpleOperationResolver();
            var factory = new FakeOperationBehaviorFactory();

            factory.OperationBehaviors.Add(new FakeOperationBehavior {
                SetPrecedence = BehaviorPrecedence.StateRecovery
            });
            var workflow = configuration.WithBehaviorFactory(factory);

            var result = sut.Resolve <SimpleTestOperation>(workflow);

            Assert.IsType <FakeOperationBehavior>(result);
            Assert.IsType <SimpleTestOperation>((result as OperationBehavior).InnerOperation);
        }
Exemple #3
0
        public void Behaviors_are_applied_sorted_by_precedence_with_the_higher_precedence_behaviors_on_the_outside_across_factories(WorkflowConfiguration configuration, FakeOperation operation)
        {
            var factory1 = new FakeOperationBehaviorFactory();

            factory1.OperationBehaviors.Add(new FakeOperationBehavior {
                SetPrecedence = BehaviorPrecedence.StateRecovery
            });
            factory1.OperationBehaviors.Add(new FakeOperationBehavior {
                SetPrecedence = BehaviorPrecedence.Logging
            });
            factory1.OperationBehaviors.Add(new FakeOperationBehavior {
                SetPrecedence = BehaviorPrecedence.WorkCompensation
            });
            var factory2 = new FakeOperationBehaviorFactory();

            factory2.OperationBehaviors.Add(new FakeOperationBehavior {
                SetPrecedence = BehaviorPrecedence.PreRecovery
            });
            factory2.OperationBehaviors.Add(new FakeOperationBehavior {
                SetPrecedence = BehaviorPrecedence.Containment
            });
            configuration.WithBehaviorFactory(factory1).WithBehaviorFactory(factory2);

            var result = OperationResolverHelper.ApplyBehaviors(operation, configuration);

            Assert.IsType <FakeOperationBehavior>(result);
            var behavior1 = (OperationBehavior)result;

            Assert.Equal(BehaviorPrecedence.Logging, behavior1.Precedence);
            Assert.IsType <FakeOperationBehavior>(behavior1.InnerOperation);
            var behavior2 = (OperationBehavior)behavior1.InnerOperation;

            Assert.Equal(BehaviorPrecedence.Containment, behavior2.Precedence);
            Assert.IsType <FakeOperationBehavior>(behavior2.InnerOperation);
            var behavior3 = (OperationBehavior)behavior2.InnerOperation;

            Assert.Equal(BehaviorPrecedence.WorkCompensation, behavior3.Precedence);
            Assert.IsType <FakeOperationBehavior>(behavior3.InnerOperation);
            var behavior4 = (OperationBehavior)behavior3.InnerOperation;

            Assert.Equal(BehaviorPrecedence.StateRecovery, behavior4.Precedence);
            Assert.IsType <FakeOperationBehavior>(behavior4.InnerOperation);
            var behavior5 = (OperationBehavior)behavior4.InnerOperation;

            Assert.Equal(BehaviorPrecedence.PreRecovery, behavior5.Precedence);
            Assert.IsType <FakeOperation>(behavior5.InnerOperation);
        }
        public void Created_input_operations_are_provided_with_input_values_when_having_behaviors(object input)
        {
            var resolver = new SimpleOperationResolver();
            var factory  = new FakeOperationBehaviorFactory();

            factory.OperationBehaviors.Add(new FakeOperationBehavior());
            var correctConfiguration = new FakeWorkflowConfiguration {
                Resolver = resolver
            }.WithBehaviorFactory(factory);
            var sut = new FakeOperation();

            sut.Initialize(correctConfiguration);

            var result = sut.PublicCreate <SimpleTestPropertyInputOperation, object>(input).GetInnermostOperation() as SimpleTestPropertyInputOperation;

            Assert.NotNull(result.Input);
            Assert.Equal(input, result.Input);
        }