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); } }