public void TransitionContext_SetVariable_ReplacesExistingVariableValue() { // Arrange Switcher switcher = new Switcher { Type = OnOffWorkflow.TYPE }; var context = new TransitionContext(switcher); var variable = new SwitcherWorkflowVariable(true); context.SetVariable <SwitcherWorkflowVariable>( SwitcherWorkflowVariable.KEY, variable); Assert.IsTrue(context .GetVariable <SwitcherWorkflowVariable>(SwitcherWorkflowVariable.KEY) .CanSwitch); variable.CanSwitch = false; // Act context.SetVariable <SwitcherWorkflowVariable>( SwitcherWorkflowVariable.KEY, variable); // Assert Assert.IsNotNull(context); Assert.IsTrue(context.HasVariables); Assert.IsTrue(context.ContainsKey(SwitcherWorkflowVariable.KEY)); Assert.IsFalse(context .GetVariable <SwitcherWorkflowVariable>(SwitcherWorkflowVariable.KEY) .CanSwitch); }
public void TriggerResult_NewInstanceWithVariables_CreatesANewInstance() { // Arrange var trigger = "SwitchOn"; Switcher switcher = new Switcher { Type = OnOffWorkflow.TYPE }; var transitionContext = new TransitionContext(switcher); var variable = new SwitcherWorkflowVariable(true); transitionContext.SetVariable <SwitcherWorkflowVariable>( SwitcherWorkflowVariable.KEY, variable); var canTrigger = true; // Act var result = new TriggerResult(trigger, transitionContext, canTrigger); // Assert Assert.IsNotNull(result); Assert.IsTrue(result.CanTrigger); Assert.IsFalse(result.IsAborted); Assert.AreSame(result.TriggerName, trigger); Assert.IsFalse(result.HasErrors); Assert.AreSame(result.CurrentState, switcher.State); var v = result.GetVariable <SwitcherWorkflowVariable>(SwitcherWorkflowVariable.KEY); Assert.IsNotNull(v); Assert.IsTrue(v.CanSwitch); }
public void TransitionContext_SetVariable_VariableIsSet() { // Arrange Switcher switcher = new Switcher { Type = OnOffWorkflow.TYPE }; var context = new TransitionContext(switcher); var variable = new SwitcherWorkflowVariable(true); // Act context.SetVariable <SwitcherWorkflowVariable>( SwitcherWorkflowVariable.KEY, variable); // Assert Assert.IsNotNull(context); Assert.IsTrue(context.HasVariables); Assert.IsTrue(context.ContainsKey(SwitcherWorkflowVariable.KEY)); }
public void TransitionContext_GetVariable_VariableReturned() { // Arrange Switcher switcher = new Switcher { Type = OnOffWorkflow.TYPE }; var context = new TransitionContext(switcher); var canSwitch = new SwitcherWorkflowVariable(true); context.SetVariable <SwitcherWorkflowVariable>( SwitcherWorkflowVariable.KEY, canSwitch); // Act var variable = context .GetVariable <SwitcherWorkflowVariable>(SwitcherWorkflowVariable.KEY); // Assert Assert.IsNotNull(variable); Assert.IsTrue(variable.CanSwitch); }