Ejemplo n.º 1
0
        private void Execute(int scenarioId)
        {
            var scenario = _scenarioRepository.GetEntirely(scenarioId);
            var executor = GetExecutorInstance();
            ExecutionResultViewModel executionResult;
            var stopwatch = Stopwatch.StartNew();

            try
            {
                executor.Execute(scenario);

                executionResult = new ExecutionResultViewModel
                {
                    ScenarioId    = scenarioId,
                    IsSuccess     = true,
                    ExecutionTime = GetEllapsedTime(stopwatch)
                };
            }
            catch (Exception exception)
            {
                executionResult = new ExecutionResultViewModel
                {
                    ScenarioId    = scenarioId,
                    IsSuccess     = false,
                    ExecutionTime = GetEllapsedTime(stopwatch),
                    Message       = exception.Message,
                    StackTrace    = exception.StackTrace
                };
            }

            if (_executionResults.ContainsKey(scenarioId))
            {
                _executionResults[scenarioId] = executionResult;
            }
            else
            {
                _executionResults.Add(scenarioId, executionResult);
            }
        }