示例#1
0
    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);
    }
示例#2
0
    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);
    }
示例#3
0
 public CAlertingState(CStateMachine sm)
   : base(sm)
 {
   Id = EStateId.ALERTING;
 }
示例#4
0
    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());
    }
示例#5
0
 public CTerminatedState(CStateMachine sm)
     : base(sm)
 {
     Id = EStateId.TERMINATED;
 }
示例#6
0
 public CHoldingState(CStateMachine sm) : base(sm)
 {
     base.Id = EStateId.HOLDING;
 }
示例#7
0
    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();
    }
示例#8
0
 public CActiveState(CStateMachine sm)
     : base(sm)
 {
     Id = EStateId.ACTIVE;
 }
示例#9
0
 public CIncomingState(CStateMachine sm)
   : base(sm)
 {
   Id = EStateId.INCOMING;
 }
示例#10
0
 public CHoldingState(CStateMachine sm)
   : base(sm)
 {
   Id = EStateId.HOLDING;
 }
示例#11
0
 public CTerminatedState(CStateMachine sm)
   : base(sm)
 {
   Id = EStateId.TERMINATED;
 }
示例#12
0
 public CReleasedState(CStateMachine sm)
   : base(sm)
 {
   Id = EStateId.RELEASED;
 }
示例#13
0
 public CActiveState(CStateMachine sm) 
   : base(sm)
 {
   Id = EStateId.ACTIVE;
 }
示例#14
0
    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);

    }
示例#15
0
    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);


    }
示例#16
0
 public CAlertingState(CStateMachine sm)
     : base(sm)
 {
     Id = EStateId.ALERTING;
 }
示例#17
0
    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();
    }
示例#18
0
 public CReleasedState(CStateMachine sm)
     : base(sm)
 {
     Id = EStateId.RELEASED;
 }
示例#19
0
    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();
    }
示例#20
0
 public CIncomingState(CStateMachine sm)
     : base(sm)
 {
     Id = EStateId.INCOMING;
 }
示例#21
0
    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;
 }
示例#23
0
 public CConnectingState(CStateMachine sm) 
   : base(sm)
 {
   Id = EStateId.CONNECTING;
 }