private int SetState(Transaction.States newState)
        {
            int action = 0;

            if (State != newState)
            {
                if (newState == Transaction.States.Trying)
                {
                    if (IsTransportUnreliable)
                    {
                        action |= Transaction.Action.StartTimerE1;
                    }

                    action |= Transaction.Action.StartTimerF;
                }
                else if (newState == Transaction.States.Completed)
                {
                    if (IsTransportUnreliable)
                    {
                        action |= Transaction.Action.StartTimerK;
                    }
                }

                State = newState;
            }

            return(action);
        }
        private int SetState(Transaction.States newState)
        {
            int action = 0;

            if (State != newState)
            {
                if (newState == Transaction.States.Completed)
                {
                    action |= Transaction.Action.StartTimerH;

                    if (IsTransportUnreliable)
                    {
                        action |= Transaction.Action.StartTimerG1;
                    }
                }

                if (newState == Transaction.States.Confirmed)
                {
                    action |= Transaction.Action.StartTimerI;
                }

                State = newState;
            }

            return(action);
        }
예제 #3
0
 protected IEnumerable <StateUnreliable> GetAllStatesExcept(Transaction.States except1, Transaction.States except2)
 {
     foreach (var state in GetAllStates())
     {
         if (state.State == except1 && state.State == except2)
         {
             yield return(state);
         }
     }
 }
예제 #4
0
 protected IEnumerable <T> GetAllTransactionsExcept(Transaction.States except1, Transaction.States except2)
 {
     foreach (var state in GetAllStates())
     {
         if (state.State != except1 && state.State != except2)
         {
             yield return(GetTransaction(state.State, state.IsTransportUnreliable));
         }
     }
 }
예제 #5
0
 protected IEnumerable <StateUnreliable> GetAllStatesFor(Transaction.States include1, Transaction.States include2)
 {
     foreach (var state in GetAllStates())
     {
         if (state.State == include1 || state.State == include2)
         {
             yield return(state);
         }
     }
 }
예제 #6
0
 protected IEnumerable <T> GetAllTransactionsFor(Transaction.States include1, Transaction.States include2)
 {
     foreach (var state in GetAllStates())
     {
         if (state.State == include1 || state.State == include2)
         {
             yield return(GetTransaction(state.State, state.IsTransportUnreliable));
         }
     }
 }
        protected void EmulateTransportEvent(bool isTransportUnreliable, Transaction.States fromState, int startStatus, int endStatus, Transaction.States toState)
        {
            for (int i = startStatus; i <= endStatus; i++)
            {
                var transaction = GetTransaction(fromState, isTransportUnreliable);
                transaction.ProccessTransport(i);

                Assert.AreEqual(toState, transaction.State);
            }
        }
        private void SetState(Transaction.States newState, ref int action)
        {
            if (State != newState)
            {
                if (newState == Transaction.States.Completed)
                {
                    action |= Transaction.Action.StartTimerJ;
                }

                State = newState;
            }
        }
        protected override T GetTransaction(Transaction.States state, bool isTransportUnreliable)
        {
            var e = GetServerEventArgs(isTransportUnreliable);

            var transaction = new T();

            if (Transaction.States.Calling != Transaction.States.Trying)
            {
                throw new InvalidProgramException();
            }

            switch (state)
            {
            case Transaction.States.Created:
                break;

            case Transaction.States.Trying:
                //case Transaction.States.Calling:
                transaction.ProccessTransactionUser(false, e);
                break;

            case Transaction.States.Proceeding:
                transaction.ProccessTransactionUser(false, e);
                transaction.ProccessTransport(100);
                break;

            case Transaction.States.Completed:
                if (isTransportUnreliable == false)
                {
                    throw new InvalidProgramException(@"States.Completed state accessable only for Unreable transport");
                }
                transaction.ProccessTransactionUser(false, e);
                transaction.ProccessTransport(300);
                break;

            case Transaction.States.Terminated:
                transaction.ProccessTransactionUser(false, e);
                transaction.ProccessTransportError();
                break;
            }

            if (state != transaction.State)
            {
                throw new InvalidProgramException();
            }

            EventArgsManager.Put(e);

            return(transaction);
        }
예제 #10
0
        protected override InviteServerTransaction GetTransaction(Transaction.States state, bool isTransportUnreliable)
        {
            var e = GetServerEventArgs(isTransportUnreliable);

            var transaction = new InviteServerTransaction();

            switch (state)
            {
            case Transaction.States.Created:
                break;

            case Transaction.States.Proceeding:
                transaction.ProccessTransport(false);
                break;

            case Transaction.States.Completed:
                transaction.ProccessTransport(false);
                transaction.ProccessTransactionUser(300, e);
                break;

            case Transaction.States.Confirmed:
                if (isTransportUnreliable == false)
                {
                    throw new InvalidProgramException(@"States.Completed state accessable only for Unreable transport");
                }
                transaction.ProccessTransport(false);
                transaction.ProccessTransactionUser(300, e);
                transaction.ProccessTransport(true);
                break;

            case Transaction.States.Terminated:
                transaction.ProccessTransport(false);
                transaction.ProccessTransportError();
                break;
            }

            if (state != transaction.State)
            {
                throw new InvalidProgramException("GetTransaction can not goto desired state");
            }

            EventArgsManager.Put(e);

            return(transaction);
        }
예제 #11
0
 protected IEnumerable <T> GetAllTransactionsExcept(Transaction.States except)
 {
     return(GetAllTransactionsExcept(except, except));
 }
예제 #12
0
 public StateUnreliable(Transaction.States state, bool isTransportUnreliable)
 {
     State = state;
     IsTransportUnreliable = isTransportUnreliable;
 }
 protected void EmulateTransportEvent(Transaction.States fromState, int startStatus, int endStatus, Transaction.States toState)
 {
     EmulateTransportEvent(true, fromState, startStatus, endStatus, toState);
     EmulateTransportEvent(false, fromState, startStatus, endStatus, toState);
 }
예제 #14
0
 protected abstract T GetTransaction(Transaction.States state, bool isTransportUnreliable);
예제 #15
0
 protected IEnumerable <StateUnreliable> GetAllStatesFor(Transaction.States include)
 {
     return(GetAllStatesFor(include, include));
 }
예제 #16
0
 protected IEnumerable <T> GetAllTransactionsFor(Transaction.States include)
 {
     return(GetAllTransactionsFor(include, include));
 }
예제 #17
0
 protected IEnumerable <StateUnreliable> GetAllStatesExcept(Transaction.States except)
 {
     return(GetAllStatesExcept(except, except));
 }