Exemplo n.º 1
0
        public void ShouldPause()
        {
            var obj = _workflow.Start(_object.Object);

            _object.Verify(x => x.GotHere("starting"), Times.Once());
            _object.Verify(x => x.SetStateId("test", "stop point"), Times.Once());
            _object.Verify(x => x.GotHere("finished"), Times.Never());
        }
 public void CanTransitionBetweenSteps()
 {
     workflow.Start(data);
     Assert.True(rule.IsInWorkflow(data));
     Assert.That(data.State, Is.EqualTo("Last"));
     ruleMock.Verify(x => x.Transition(data, "Last"));
 }
Exemplo n.º 3
0
        /// <summary>
        /// For resuming a workflow that has already begun or starting a workflow on a new
        /// object.
        /// </summary>
        /// <param name="initializer"></param>
        /// <param name="parameters">Optional parameters for this workflow segment</param>
        /// <returns></returns>
        public virtual T Start(T initializer, IDictionary <string, object> parameters)
        {
            InitializeWorkflowIfNecessary();
            var beginning = initializer.GetStateId(_workflow.WorkflowId);

            T ret = initializer;

            if (Validate(initializer))
            {
                if (parameters != null && parameters.Count == 0)
                {
                    ret = _workflow.Start(initializer);
                }
                else
                {
                    ret = _workflow.StartWithParams(initializer, parameters);
                }
            }

            object ending = (ret != null)? ret.GetStateId(_workflow.WorkflowId) : null;

            OnFinished(ret, beginning, ending);

            return(ret);
        }
Exemplo n.º 4
0
 public void CanEnterWorkflow()
 {
     workflow.Start(data);
     Assert.True(rule.IsInWorkflow(data));
     Assert.That(data.State, Is.EqualTo("First"));
     ruleMock.Verify(x => x.Begin(data, "First"));
 }
Exemplo n.º 5
0
 public void CanExitWorkflow()
 {
     workflow.Start(data);
     Assert.False(rule.IsInWorkflow(data));
     Assert.That(data.State, Is.Null);
     ruleMock.Verify(x => x.End(data));
 }
Exemplo n.º 6
0
 public void ShouldHitEveryStateWhenNoConstraintsFail()
 {
     tracker = 0;
     sut.Start(mock.Object);
     sut.Start(mock.Object);
     mock.Verify(x => x.Feedback("branch point"), Times.Once());
     mock.Verify(x => x.Feedback("first point"), Times.Once());
     mock.Verify(x => x.Feedback("second point"), Times.Once());
 }