public void LoadingAnInitializedStateMachine( IAsyncStateMachine <string, int> machine, Exception receivedException) { "establish an started state machine".x(() => { var stateMachineDefinitionBuilder = new StateMachineDefinitionBuilder <string, int>(); stateMachineDefinitionBuilder.In("initial"); machine = stateMachineDefinitionBuilder .WithInitialState("initial") .Build() .CreatePassiveStateMachine(); machine.Start(); }); "when state machine is loaded".x(async() => receivedException = await Catch.Exception(async() => await machine.Load(A.Fake <IAsyncStateMachineLoader <string> >()))); "it should throw invalid operation exception".x(() => { receivedException.Should().BeOfType <InvalidOperationException>(); receivedException.Message.Should().Be(ExceptionMessages.StateMachineIsAlreadyInitialized); }); }