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); }
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); } } }
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)); } } }
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); } } }
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); }
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); }
protected IEnumerable <T> GetAllTransactionsExcept(Transaction.States except) { return(GetAllTransactionsExcept(except, except)); }
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); }
protected abstract T GetTransaction(Transaction.States state, bool isTransportUnreliable);
protected IEnumerable <StateUnreliable> GetAllStatesFor(Transaction.States include) { return(GetAllStatesFor(include, include)); }
protected IEnumerable <T> GetAllTransactionsFor(Transaction.States include) { return(GetAllTransactionsFor(include, include)); }
protected IEnumerable <StateUnreliable> GetAllStatesExcept(Transaction.States except) { return(GetAllStatesExcept(except, except)); }