Ejemplo n.º 1
0
 private void Closing(RecorderEvent rEvent)
 {
     if (Name == rEvent.Name)
     {
         TransitionTo(m_StateClosing, s_TranIdx_Opened_Closing);
         PostFIFO(new RecorderEvent(InternalSignal.RecorderClosing, rEvent));
     }
 }
Ejemplo n.º 2
0
 private void Opening(RecorderEvent rEvent, int chainIndex)
 {
     if (Name == rEvent.Name)
     {
         TransitionTo(m_StateOpening, chainIndex);
         PostFIFO(new RecorderEvent(InternalSignal.RecorderOpening, rEvent));
     }
 }
Ejemplo n.º 3
0
 private void Close(RecorderEvent rEvent)
 {
     if (Name == rEvent.Name)
     {
         try
         {
             CloseRecorder();
             TransitionTo(m_StateClosed, s_TranIdx_Closing_Closed);
         }
         catch (Exception ex)
         {
             TransitionTo(m_StateFaulted, s_TranIdx_Closing_Faulted);
         }
     }
 }
Ejemplo n.º 4
0
        internal RecorderEvent(InternalSignal signal, RecorderEvent source)
            : base((int)signal)
        {
            switch (signal)
            {
            case InternalSignal.RecorderOpening:
            case InternalSignal.RecorderClosing:
                Name                  = source.Name;
                Location              = source.Location;
                EntryFormat           = source.EntryFormat;
                EntryStyle            = source.EntryStyle;
                Values                = source.Values;
                CommandFilter         = source.CommandFilter;
                ResponseFilter        = source.ResponseFilter;
                Entry                 = source.Entry;
                Error                 = source.Error;
                AdditionalDescription = source.AdditionalDescription;
                break;

            default:
                throw new ArgumentException("Invalid internal recorder signal.", "signal");
            }
        }
Ejemplo n.º 5
0
        private void Open(RecorderEvent rEvent)
        {
            if (Name == rEvent.Name)
            {
                try
                {
                    // DESIGN NOTE:
                    // If the Recorder is open, close it. This allows an existing Recorder to be reused to create additional files...
                    CloseRecorder();

                    CommandEvaluators  = ProcessFilter(rEvent.CommandFilter);
                    ResponseEvaluators = ProcessFilter(rEvent.ResponseFilter);
                    EntryFormat        = rEvent.EntryFormat;
                    EntryStyle         = rEvent.EntryStyle;
                    Values             = rEvent.Values;

                    // DESIGN NOTE:
                    // Detect if location is command dependent and defer open...
                    if (rEvent.Location.Contains("{Command") || rEvent.Location.Contains("{Response"))
                    {
                        LocationFormat = rEvent.Location;
                        qf4net.QF.Instance.Publish(new RecorderEvent(QFSignal.RecorderOpenPending, Name, null));
                    }
                    else
                    {
                        Recorder.Open(rEvent.Location);
                    }

                    TransitionTo(m_StateOpened, s_TranIdx_Opening_Opened);
                }
                catch (Exception ex)
                {
                    TransitionTo(m_StateFaulted, s_TranIdx_Opening_Faulted);
                }
            }
        }
Ejemplo n.º 6
0
        private void Record(RecorderEvent rEvent)
        {
            // DESIGN NOTE:
            // Recorders listen to all broadcasts and filter by entry evaluation...
            if (!string.IsNullOrEmpty(rEvent.Entry))
            {
                try
                {
                    // TODO:
                    // 1. Detect & Save Command
                    // 2. On response detection, fire Writing event w/ Command & Response
                    // 3. Either:
                    //      - Detect deferred Open and Open using formatted location
                    //      - Record resulting formatted entry

                    // TODO: Refine logic to include edge scenarios
                    // 1. EntryFormat only contains Command reference
                    // 2. EntryFormat only contains Response reference
                    // 3. EntryFormat contains neither
                    // 3. EntryFormat empty (null)

                    if (EvaluateEntry(CommandEvaluators, rEvent.Entry))
                    {
                        ActiveCommand = rEvent.Entry;
                    }
                    else if (!string.IsNullOrEmpty(ActiveCommand))
                    {
                        string location = string.Empty;
                        if (!string.IsNullOrEmpty(LocationFormat))
                        {
                            try
                            {
                                Recorder.OnOpening(rEvent.TestName, rEvent.StepNumber, LocationFormat, Values, ActiveCommand, rEvent.Entry, ref location);
                                if (string.IsNullOrEmpty(location))
                                {
                                    throw new ArgumentNullException("Invalid resulting Location in Recorder.");
                                }
                            }
                            catch (Exception ex)
                            {
                                OnError(ex);
                                throw ex;
                            }
                            Recorder.Open(location);
                            LocationFormat = string.Empty;
                        }

                        string entry = string.Empty;
                        if (EvaluateEntry(ResponseEvaluators, rEvent.Entry))
                        {
                            try
                            {
                                if (EntryStyle == EntryStyle.Single)
                                {
                                    Recorder.OnRecording(rEvent.TestName, rEvent.StepNumber, EntryFormat, Values, ActiveCommand, rEvent.Entry, ref entry);
                                }
                                else
                                {
                                    string lines = string.Empty;
                                    foreach (string line in rEvent.Entry.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
                                    {
                                        entry = string.Empty;
                                        string format = EntryFormat.Replace("{Response[*]}", line);

                                        Recorder.OnRecording(rEvent.TestName, rEvent.StepNumber, format, Values, ActiveCommand, rEvent.Entry, ref entry);
                                        lines += entry + "\r\n";
                                    }
                                    entry = lines;
                                }
                                if (string.IsNullOrEmpty(entry))
                                {
                                    throw new ArgumentNullException("Invalid resulting Entry in Recorder.");
                                }
                            }
                            catch (Exception ex)
                            {
                                OnError(ex);
                                throw ex;
                            }
                        }

                        Recorder.Record(entry);
                    }
                }
                catch (Exception ex)
                {
                    TransitionTo(m_StateFaulted, s_TranIdx_Opened_Faulted);
                }
            }
        }