public void testCallFeaturesCallHold() { CStateMachine sm1 = new CStateMachine(); sm1.State.incomingCall("1234",""); Assert.AreEqual(EStateId.INCOMING, sm1.StateId); Assert.AreEqual(true, sm1.Incoming); Assert.AreEqual("1234", sm1.CallingNumber); Assert.AreEqual(sm1.RuntimeDuration.ToString(), TimeSpan.Zero.ToString()); sm1.State.acceptCall(); Assert.AreEqual(EStateId.ACTIVE, sm1.StateId); Assert.AreEqual(true, sm1.Counting); sm1.State.holdCall(); Assert.AreEqual(EStateId.ACTIVE, sm1.StateId); // still ACTIVE (waiting confirmation) sm1.State.onHoldConfirm(); Assert.AreEqual(EStateId.HOLDING, sm1.StateId); // check twice hold sm1.State.holdCall(); Assert.AreEqual(EStateId.HOLDING, sm1.StateId); sm1.State.retrieveCall(); Assert.AreEqual(EStateId.ACTIVE, sm1.StateId); sm1.State.holdCall(); Assert.AreEqual(EStateId.ACTIVE, sm1.StateId); // still ACTIVE (waiting confirmation) sm1.State.onHoldConfirm(); Assert.AreEqual(EStateId.HOLDING, sm1.StateId); sm1.destroy(); Assert.AreEqual(EStateId.IDLE, sm1.StateId); }
public void testCallFeaturesCallHoldMultiple() { CStateMachine sm1 = new CStateMachine(); sm1.State.incomingCall("1234",""); Assert.AreEqual(EStateId.INCOMING, sm1.StateId); Assert.AreEqual(true, sm1.Incoming); Assert.AreEqual("1234", sm1.CallingNumber); Assert.AreEqual(sm1.RuntimeDuration.ToString(), TimeSpan.Zero.ToString()); sm1.State.acceptCall(); Assert.AreEqual(EStateId.ACTIVE, sm1.StateId); Assert.AreEqual(true, sm1.Counting); sm1.State.holdCall(); Assert.AreEqual(EStateId.ACTIVE, sm1.StateId); // still ACTIVE (waiting confirmation) sm1.State.onHoldConfirm(); Assert.AreEqual(EStateId.HOLDING, sm1.StateId); // next call CStateMachine sm2 = new CStateMachine(); sm2.State.makeCall("4444", 0); Assert.AreEqual(EStateId.CONNECTING, sm2.StateId); Assert.AreEqual(false, sm2.Incoming); Assert.AreEqual("4444", sm2.CallingNumber); sm2.State.onAlerting(); Assert.AreEqual(EStateId.ALERTING, sm2.StateId); Assert.AreEqual(false, sm2.Counting); sm2.State.onConnect(); Assert.AreEqual(EStateId.ACTIVE, sm2.StateId); Assert.AreEqual(true, sm2.Counting); sm2.State.holdCall(); Assert.AreEqual(EStateId.ACTIVE, sm2.StateId); // still ACTIVE (waiting confirmation) sm2.State.onHoldConfirm(); Assert.AreEqual(EStateId.HOLDING, sm2.StateId); // release first sm1.State.onReleased(); Assert.AreEqual(EStateId.RELEASED, sm1.StateId); sm2.State.onHoldConfirm(); Assert.AreEqual(EStateId.HOLDING, sm2.StateId); sm2.State.endCall(); Assert.AreEqual(EStateId.IDLE, sm2.StateId); sm2.State.onReleased(); Assert.AreEqual(EStateId.IDLE, sm2.StateId); }
public CAlertingState(CStateMachine sm) : base(sm) { Id = EStateId.ALERTING; }
public void testStateMachineEventHandlingIncoming() { CStateMachine sm1 = new CStateMachine(); sm1.State.incomingCall("1234",""); Assert.AreEqual(EStateId.INCOMING, sm1.StateId); Assert.AreEqual(true, sm1.Incoming); Assert.AreEqual("1234", sm1.CallingNumber); Assert.AreEqual(sm1.RuntimeDuration.ToString(), TimeSpan.Zero.ToString()); sm1.State.acceptCall(); Assert.AreEqual(EStateId.ACTIVE, sm1.StateId); Assert.AreEqual(true, sm1.Counting); //Assert.AreNotEqual(sm1.RuntimeDuration.ToString(), TimeSpan.Zero.ToString()); sm1.State.onReleased(); Assert.AreEqual(EStateId.RELEASED, sm1.StateId); Assert.AreEqual(true, sm1.Counting); //Assert.AreNotEqual(sm1.RuntimeDuration.ToString(), TimeSpan.Zero.ToString()); }
public CTerminatedState(CStateMachine sm) : base(sm) { Id = EStateId.TERMINATED; }
public CHoldingState(CStateMachine sm) : base(sm) { base.Id = EStateId.HOLDING; }
public void testStateMachineCreateSequence() { CStateMachine sm = new CStateMachine(); Assert.AreEqual(-1, sm.Session); Assert.AreEqual(TimeSpan.Zero, sm.Duration); Assert.AreEqual(EStateId.IDLE, sm.StateId); // changing state sm.changeState(EStateId.INCOMING); Assert.AreEqual(EStateId.INCOMING, sm.StateId); Assert.AreEqual("INCOMING", sm.StateId.ToString()); sm.changeState(EStateId.ALERTING); Assert.AreEqual(EStateId.ALERTING, sm.StateId); Assert.AreEqual("ALERTING", sm.StateId.ToString()); sm.changeState(EStateId.CONNECTING); Assert.AreEqual(EStateId.CONNECTING, sm.StateId); Assert.AreEqual("CONNECTING", sm.StateId.ToString()); sm.changeState(EStateId.RELEASED); Assert.AreEqual(EStateId.RELEASED, sm.StateId); Assert.AreEqual("RELEASED", sm.StateId.ToString()); sm.destroy(); // Second sm = new CStateMachine(); Assert.AreEqual(-1, sm.Session); Assert.AreEqual(TimeSpan.Zero, sm.Duration); Assert.AreEqual(EStateId.IDLE, sm.StateId); // changing state sm.changeState(EStateId.INCOMING); Assert.AreEqual(EStateId.INCOMING, sm.StateId); Assert.AreEqual("INCOMING", sm.StateId.ToString()); sm.changeState(EStateId.ALERTING); Assert.AreEqual(EStateId.ALERTING, sm.StateId); Assert.AreEqual("ALERTING", sm.StateId.ToString()); sm.changeState(EStateId.CONNECTING); Assert.AreEqual(EStateId.CONNECTING, sm.StateId); Assert.AreEqual("CONNECTING", sm.StateId.ToString()); sm.changeState(EStateId.RELEASED); Assert.AreEqual(EStateId.RELEASED, sm.StateId); Assert.AreEqual("RELEASED", sm.StateId.ToString()); sm.destroy(); // third sm = new CStateMachine(); Assert.AreEqual(-1, sm.Session); Assert.AreEqual(TimeSpan.Zero, sm.Duration); Assert.AreEqual(EStateId.IDLE, sm.StateId); // changing state sm.changeState(EStateId.INCOMING); Assert.AreEqual(EStateId.INCOMING, sm.StateId); Assert.AreEqual("INCOMING", sm.StateId.ToString()); sm.changeState(EStateId.ALERTING); Assert.AreEqual(EStateId.ALERTING, sm.StateId); Assert.AreEqual("ALERTING", sm.StateId.ToString()); sm.changeState(EStateId.CONNECTING); Assert.AreEqual(EStateId.CONNECTING, sm.StateId); Assert.AreEqual("CONNECTING", sm.StateId.ToString()); sm.changeState(EStateId.RELEASED); Assert.AreEqual(EStateId.RELEASED, sm.StateId); Assert.AreEqual("RELEASED", sm.StateId.ToString()); sm.destroy(); }
public CActiveState(CStateMachine sm) : base(sm) { Id = EStateId.ACTIVE; }
public CIncomingState(CStateMachine sm) : base(sm) { Id = EStateId.INCOMING; }
public CHoldingState(CStateMachine sm) : base(sm) { Id = EStateId.HOLDING; }
public CReleasedState(CStateMachine sm) : base(sm) { Id = EStateId.RELEASED; }
public void testCallFeaturesCallWaiting() { // out call CStateMachine sm2 = new CStateMachine(); sm2.State.makeCall("4444", 0); Assert.AreEqual(EStateId.CONNECTING, sm2.StateId); Assert.AreEqual(false, sm2.Incoming); Assert.AreEqual("4444", sm2.CallingNumber); sm2.State.onAlerting(); Assert.AreEqual(EStateId.ALERTING, sm2.StateId); Assert.AreEqual(false, sm2.Counting); sm2.State.onConnect(); Assert.AreEqual(EStateId.ACTIVE, sm2.StateId); Assert.AreEqual(true, sm2.Counting); // inc call CStateMachine sm1 = new CStateMachine(); sm1.State.incomingCall("1234",""); Assert.AreEqual(EStateId.INCOMING, sm1.StateId); Assert.AreEqual(true, sm1.Incoming); Assert.AreEqual("1234", sm1.CallingNumber); Assert.AreEqual(sm1.RuntimeDuration.ToString(), TimeSpan.Zero.ToString()); // check what happens here? sm1.State.acceptCall(); Assert.AreEqual(EStateId.ACTIVE, sm1.StateId); Assert.AreEqual(true, sm1.Counting); // this should be done automatically by call manager // Here we do not test call manager //Assert.AreEqual(EStateId.HOLDING, sm2.StateId); sm1.State.endCall(); sm2.State.endCall(); Assert.AreEqual(EStateId.IDLE, sm1.StateId); Assert.AreEqual(EStateId.IDLE, sm2.StateId); sm1.State.onReleased(); sm2.State.onReleased(); Assert.AreEqual(EStateId.IDLE, sm1.StateId); Assert.AreEqual(EStateId.IDLE, sm2.StateId); }
public void testMultipleStateMachinesSequence() { CStateMachine sm1 = new CStateMachine(); Assert.AreEqual(-1, sm1.Session); Assert.AreEqual(TimeSpan.Zero, sm1.Duration); Assert.AreEqual(EStateId.IDLE, sm1.StateId); // changing state sm1.changeState(EStateId.INCOMING); Assert.AreEqual(EStateId.INCOMING, sm1.StateId); sm1.destroy(); CStateMachine sm2 = new CStateMachine(); Assert.AreEqual(-1, sm2.Session); Assert.AreEqual(TimeSpan.Zero, sm2.Duration); Assert.AreEqual(EStateId.IDLE, sm2.StateId); sm2.changeState(EStateId.ALERTING); Assert.AreEqual(EStateId.ALERTING, sm2.StateId); sm2.destroy(); CStateMachine sm3 = new CStateMachine(); Assert.AreEqual(-1, sm3.Session); Assert.AreEqual(TimeSpan.Zero, sm3.Duration); Assert.AreEqual(EStateId.IDLE, sm3.StateId); sm3.changeState(EStateId.CONNECTING); Assert.AreEqual(EStateId.CONNECTING, sm3.StateId); sm3.destroy(); Assert.AreEqual(EStateId.IDLE, sm1.StateId); Assert.AreEqual(EStateId.IDLE, sm2.StateId); Assert.AreEqual(EStateId.IDLE, sm3.StateId); }
public void testIncomingCall() { CStateMachine sm1 = new CStateMachine(); Assert.AreEqual(EStateId.IDLE, sm1.StateId); Assert.AreEqual(false, sm1.Incoming); sm1.changeState(EStateId.INCOMING); Assert.AreEqual(EStateId.INCOMING, sm1.StateId); Assert.AreEqual(true, sm1.Incoming); Assert.AreEqual(sm1.RuntimeDuration, TimeSpan.Zero); sm1.changeState(EStateId.ACTIVE); Assert.AreEqual(EStateId.ACTIVE, sm1.StateId); Assert.AreEqual(true, sm1.Incoming); Assert.AreNotSame(sm1.RuntimeDuration, TimeSpan.Zero); sm1.destroy(); }
public void testOutgoingCall() { CStateMachine sm1 = new CStateMachine(); Assert.AreEqual(EStateId.IDLE, sm1.StateId); Assert.AreEqual(false, sm1.Incoming); sm1.changeState(EStateId.CONNECTING); Assert.AreEqual(EStateId.CONNECTING, sm1.StateId); Assert.AreEqual(false, sm1.Incoming); Assert.AreEqual(sm1.RuntimeDuration, TimeSpan.Zero); sm1.changeState(EStateId.ALERTING); Assert.AreEqual(EStateId.ALERTING, sm1.StateId); Assert.AreEqual(false, sm1.Incoming); Assert.AreEqual(sm1.RuntimeDuration, TimeSpan.Zero); sm1.changeState(EStateId.ACTIVE); Assert.AreEqual(EStateId.ACTIVE, sm1.StateId); Assert.AreEqual("ACTIVE", sm1.StateId.ToString()); Assert.AreEqual(false, sm1.Incoming); Assert.AreEqual(true, sm1.Counting); Assert.AreNotSame(sm1.RuntimeDuration, TimeSpan.Zero); sm1.destroy(); }
public void testStateMachineEventHandlingOutgoing() { CStateMachine sm1 = new CStateMachine(); sm1.State.makeCall("1234", 0); Assert.AreEqual(EStateId.CONNECTING, sm1.StateId); Assert.AreEqual(false, sm1.Incoming); Assert.AreEqual("1234", sm1.CallingNumber); Assert.AreEqual(sm1.RuntimeDuration, TimeSpan.Zero); sm1.State.onAlerting(); Assert.AreEqual(EStateId.ALERTING, sm1.StateId); Assert.AreEqual(false, sm1.Counting); Assert.AreEqual(sm1.RuntimeDuration, TimeSpan.Zero); sm1.State.onConnect(); Assert.AreEqual(EStateId.ACTIVE, sm1.StateId); Assert.AreEqual(true, sm1.Counting); //Assert.AreNotEqual(sm1.RuntimeDuration.ToString(), TimeSpan.Zero.ToString()); sm1.State.onReleased(); Assert.AreEqual(EStateId.RELEASED, sm1.StateId); Assert.AreEqual(true, sm1.Counting); //Assert.AreNotEqual(sm1.RuntimeDuration.ToString(), TimeSpan.Zero.ToString()); }
public CConnectingState(CStateMachine sm) : base(sm) { base.Id = EStateId.CONNECTING; }
public CConnectingState(CStateMachine sm) : base(sm) { Id = EStateId.CONNECTING; }