public void States_should_automatically_be_created_for_the_class() { ExampleStateMachine example = new ExampleStateMachine(); Assert.IsNotNull(ExampleStateMachine.Initial); Assert.AreEqual(ExampleStateMachine.Initial.Name, "Initial"); }
public void Typed_events_should_carry_their_data_to_the_expression_other() { ExampleStateMachine example = new ExampleStateMachine(); example.SubmitCommentCard(new CommentCard { IsComplaint = false }); Assert.AreEqual(ExampleStateMachine.Completed, example.CurrentState); }
public void Typed_events_should_carry_their_data_to_the_expression() { ExampleStateMachine example = new ExampleStateMachine(); example.SubmitCommentCard(new CommentCard { IsComplaint = true }); Assert.AreEqual(ExampleStateMachine.WaitingForManager, example.CurrentState); }
public void Multiple_expressions_per_event_should_run_in_order() { ExampleStateMachine example = new ExampleStateMachine(); example.SubmitCommentCard(new CommentCard { IsComplaint = true }); Assert.AreEqual(ExampleStateMachine.WaitingForManager, example.CurrentState); example.BurnCommentCard(); Assert.AreEqual(ExampleStateMachine.Completed, example.CurrentState); }
public void The_transitions_should_work() { ExampleStateMachine example = new ExampleStateMachine(); example.SubmitOrder(); Assert.AreEqual(ExampleStateMachine.WaitingForPayment, example.CurrentState); example.SubmitPayment(); Assert.AreEqual(ExampleStateMachine.WaitingForPaymentApproval, example.CurrentState); example.ApprovePayment(); Assert.AreEqual(ExampleStateMachine.Completed, example.CurrentState); }
public void Serializing_a_state_machine_should_restore_properly() { ExampleStateMachine example = new ExampleStateMachine(); example.SubmitOrder(); byte[] data; using (MemoryStream output = new MemoryStream()) { _formatter.Serialize(output, example); data = output.ToArray(); } using (MemoryStream input = new MemoryStream(data)) { var copied = (ExampleStateMachine)_formatter.Deserialize(input); Assert.AreEqual(ExampleStateMachine.WaitingForPayment, copied.CurrentState); } }
public void The_initial_state_should_be_set() { ExampleStateMachine example = new ExampleStateMachine(); Assert.AreEqual(ExampleStateMachine.Initial, example.CurrentState); }
public void I_want_to_see_what_you_see() { var machine = new ExampleStateMachine(); StateMachineInspector.Trace(machine); }