public SimpleParallel(string name, SimpleParallelPolicy policy, IBehaviour <TContext> first, IBehaviour <TContext> second) : base(name, new[] { first, second }) { Policy = policy; _first = first; _second = second; _behave = policy == SimpleParallelPolicy.BothMustSucceed ? (Func <TContext, BehaviourStatus>)BothMustSucceedBehaviour : OnlyOneMustSucceedBehaviour; }
public static FluentBuilder <TContext> SimpleParallel <TContext>( this FluentBuilder <TContext> builder, string name, SimpleParallelPolicy policy = SimpleParallelPolicy.BothMustSucceed) { return(builder.PushComposite(children => new SimpleParallel <TContext>(name, policy, children[0], children[1]))); }
public void WhenTickedAndInACompletedStatus_ChildrenShouldAllBeTicked(SimpleParallelPolicy policy) { var first = new MockBehaviour { ReturnStatus = BehaviourStatus.Succeeded }; var second = new MockBehaviour { ReturnStatus = BehaviourStatus.Succeeded }; var sut = new SimpleParallel <MockContext>(policy, first, second); sut.Tick(new MockContext()); sut.Tick(new MockContext()); Assert.That(first.UpdateCallCount, Is.EqualTo(2)); Assert.That(second.UpdateCallCount, Is.EqualTo(2)); }
public void WhenFirstTicked_ChildrenShouldAllBeStarted(SimpleParallelPolicy policy) { var first = new MockBehaviour { ReturnStatus = BehaviourStatus.Running }; var second = new MockBehaviour { ReturnStatus = BehaviourStatus.Running }; var sut = new SimpleParallel <MockContext>(policy, first, second); sut.Tick(new MockContext()); Assert.That(first.InitializeCallCount, Is.EqualTo(1)); Assert.That(second.InitializeCallCount, Is.EqualTo(1)); Assert.That(first.UpdateCallCount, Is.EqualTo(1)); Assert.That(second.UpdateCallCount, Is.EqualTo(1)); }
public SimpleParallel(SimpleParallelPolicy policy, IBehaviour <TContext> first, IBehaviour <TContext> second) : this("SimpleParallel", policy, first, second) { }
public SimpleParallelNode(SimpleParallelPolicy policy) { Policy = policy; }