public void AddAutoFallbackTransition_throws_InvalidOperationException_if_AutoTransition_already_set() { var stateMachine = new StateMachineAsync <Sale, SaleState, SaleEvent>(sale => sale.State, (sale, newState) => sale.State = newState); var sut = new StateConfigurationAsync <Sale, SaleState, SaleEvent>(SaleState.ChangeDue, stateMachine); sut.AddAutoFallbackTransition(SaleEvent.Pay, SaleState.ChangeDue, (sale, _) => Task.FromResult(result: true)); Assert.Throws <InvalidOperationException>(() => sut.AddAutoFallbackTransition(SaleEvent.Pay, SaleState.ChangeDue, (sale, _) => Task.FromResult(result: true))); }
public void AddAutoFallbackTransitionWRequest_throws_ArgumentNullException_if_Condition_null() { var stateMachine = new StateMachineAsync <Sale, SaleState, SaleEvent>(sale => sale.State, (sale, newState) => sale.State = newState); var sut = new StateConfigurationAsync <Sale, SaleState, SaleEvent>(SaleState.ChangeDue, stateMachine); Assert.Throws <ArgumentNullException>(() => sut.AddAutoFallbackTransition <string>(SaleEvent.Pay, SaleState.ChangeDue, condition: null)); }
public void AddAutoFallbackTransitionWRequest_adds_transition() { var stateMachine = new StateMachineAsync <Sale, SaleState, SaleEvent>(sale => sale.State, (sale, newState) => sale.State = newState); var sut = new StateConfigurationAsync <Sale, SaleState, SaleEvent>(SaleState.ChangeDue, stateMachine); sut.AddAutoFallbackTransition <string>(SaleEvent.Pay, SaleState.ChangeDue, condition: (sale, s, _) => Task.FromResult(true)); Assert.Single((stateMachine.ConfigureState(SaleState.ChangeDue) as StateConfigurationAsync <Sale, SaleState, SaleEvent>).AutoTransitions); }