public void CreateAndRunStateStringSync()
        {
            // Create a state machine that uses ints to describe states and triggers
            // Using an int as the type requires a conversion function
            var target = new CodeStateMachine();

            var tracking = new MemoryTrackingParticipant();
            target.AddTracking(tracking);

            try
            {
                // State 1 will wait for trigger 2 which will transition to state 2
                target.AddState("One").When("Two", "Two");

                // State 2 will be the final state
                target.AddState("Two");

                // Will run the state machine and fire the trigger when ready
                target.Fire("Two").WaitForComplete();

                AssertState.OccursInOrder(target.DisplayName, tracking.Records, "One", "Two");
            }
            finally
            {
                tracking.Trace();

                Trace.WriteLine(string.Empty);
                Trace.WriteLine("*** Workflow Definition ***");
                Trace.WriteLine(XamlServices.Save(target.WorkflowStateMachine));
            }
        }
        public void AddTwoNumbersAndStoreInVariable()
        {
            // Create a state machine that uses ints to describe states and triggers
            // Using an int as the type requires a conversion function
            var target = new CodeStateMachine<TestState, TestTrigger>();

            var tracking = new MemoryTrackingParticipant();
            target.AddTracking(tracking);

            try
            {
                // Setup arguments that can be passed into the workflow
                // var arg1 = target.CreateInArgument<int>("Num1", 1);

                // Create a variable
                var sum = target.CreateVariable("Sum", typeof(int));

                // TODO: Think more about state, storing it, load it and passing it to activities

                // Access a variable from an expression
                target[TestState.One].Exit(
                    new Assign { To = new OutArgument<int>(sum), Value = new InArgument<int>(3) }).When(
                        TestTrigger.B, TestState.Two);

                // Will run the state machine and fire the trigger when ready
                // then wait for it to complete
                target.Fire(TestTrigger.B).WaitForComplete();

                AssertState.OccursInOrder(target.DisplayName, tracking.Records, TestState.One, TestState.Two);
            }
            finally
            {
                tracking.Trace();

                Trace.WriteLine(string.Empty);
                Trace.WriteLine("*** Workflow Definition ***");
                Trace.WriteLine(target.Xaml);
            }
        }
        public void CreateAndRunStateStringEnum()
        {
            // Create a state machine that uses ints to describe states and triggers
            // Using an int as the type requires a conversion function
            var target = new CodeStateMachine<TestState, TestTrigger>();

            var tracking = new MemoryTrackingParticipant();
            target.AddTracking(tracking);

            try
            {
                // State One will wait for trigger B which will transition to state Two
                target[TestState.One].When(TestTrigger.B, TestState.Two);

                // Will run the state machine and fire the trigger when ready
                // then wait for it to complete
                target.Fire(TestTrigger.B).WaitForComplete();

                AssertState.OccursInOrder(target.DisplayName, tracking.Records, TestState.One, TestState.Two);
            }
            finally
            {
                tracking.Trace();

                Trace.WriteLine(string.Empty);
                Trace.WriteLine("*** Workflow Definition ***");
                Trace.WriteLine(XamlServices.Save(target.WorkflowStateMachine));
            }
        }