public void Initialize(ISequenceFlowContainer sequenceData)
        {
            _stateManageContext = new StateManageContext(_globalInfo, sequenceData);
            if (sequenceData is ITestProject)
            {
                ITestProject       testProject            = (ITestProject)sequenceData;
                SessionStateHandle testProjectStateHandle = new SessionStateHandle(testProject,
                                                                                   _stateManageContext);
                _sessionStateHandles.Add(testProjectStateHandle.Session, testProjectStateHandle);

                for (int index = 0; index < testProject.SequenceGroups.Count; index++)
                {
                    SessionStateHandle stateHandle = new SessionStateHandle(index, testProject.SequenceGroups[index],
                                                                            _stateManageContext);
                    _sessionStateHandles.Add(stateHandle.Session, stateHandle);
                }
            }
            else
            {
                SessionStateHandle stateHandle = new SessionStateHandle(0, (ISequenceGroup)sequenceData,
                                                                        _stateManageContext);
                _sessionStateHandles.Add(stateHandle.Session, stateHandle);
            }

            _globalInfo.EventDispatcher = _stateManageContext.EventDispatcher;
        }
Beispiel #2
0
        private bool HandleStatusMessage(MessageBase message)
        {
            SessionStateHandle stateHandle   = _sessionStateHandles[message.Id];
            StatusMessage      statusMessage = (StatusMessage)message;
            bool result = true;

            switch (statusMessage.Name)
            {
            case MessageNames.StartStatusName:
                if (RuntimeState.StartIdle == _globalInfo.StateMachine.State)
                {
                    _stateManageContext.TestInstance.StartTime = message.Time;
                    _stateManageContext.DatabaseProxy.UpdateData(_stateManageContext.TestInstance);

                    _globalInfo.StateMachine.State = RuntimeState.Running;
                    _stateManageContext.EventDispatcher.RaiseEvent(Constants.TestProjectStart,
                                                                   CommonConst.TestGroupSession, _stateManageContext.TestResults);

                    stateHandle.HandleStatusMessage(statusMessage);
                }
                break;

            case MessageNames.ReportStatusName:
                stateHandle.HandleStatusMessage(statusMessage);
                break;

            case MessageNames.ResultStatusName:
            case MessageNames.ErrorStatusName:
                stateHandle.HandleStatusMessage(statusMessage);

                if (_stateManageContext.IsAllTestOver)
                {
                    SetTestInstanceEndTime(message.Time);
                    _stateManageContext.DatabaseProxy.UpdateData(_stateManageContext.TestInstance);

                    _globalInfo.StateMachine.State = RuntimeState.Over;
                    _stateManageContext.EventDispatcher.RaiseEvent(Constants.TestProjectOver,
                                                                   CommonConst.TestGroupSession, _stateManageContext.TestResults);
                }
                break;

            case MessageNames.HearBeatStatusName:
                stateHandle.HandleStatusMessage(statusMessage);
                break;

            default:
                throw new InvalidProgramException();
                break;
            }
            return(result);
        }