Ejemplo n.º 1
0
        /// <summary>
        /// Returns the next boolean choice.
        /// </summary>
        /// <param name="maxValue">Max value</param>
        /// <param name="next">Next</param>
        /// <returns>Boolean</returns>
        public bool GetNextBooleanChoice(int maxValue, out bool next)
        {
            if (IsReplaying)
            {
                ScheduleStep nextStep = null;

                try
                {
                    if (ScheduledSteps >= ScheduleTrace.Count)
                    {
                        ErrorText = "Trace is not reproducible: execution is longer than trace.";
                        throw new InvalidOperationException(ErrorText);
                    }

                    nextStep = ScheduleTrace[ScheduledSteps];
                    if (nextStep.Type != ScheduleStepType.NondeterministicChoice)
                    {
                        ErrorText = "Trace is not reproducible: next step is not a nondeterministic choice.";
                        throw new InvalidOperationException(ErrorText);
                    }

                    if (nextStep.BooleanChoice == null)
                    {
                        ErrorText = "Trace is not reproducible: next step is not a nondeterministic boolean choice.";
                        throw new InvalidOperationException(ErrorText);
                    }
                }
                catch (InvalidOperationException ex)
                {
                    if (SuffixStrategy == null)
                    {
                        if (!Configuration.DisableEnvironmentExit)
                        {
                            Error.ReportAndExit(ex.Message);
                        }

                        next = false;
                        return(false);
                    }
                    else
                    {
                        IsReplaying = false;
                        return(SuffixStrategy.GetNextBooleanChoice(maxValue, out next));
                    }
                }

                next = nextStep.BooleanChoice.Value;
                ScheduledSteps++;
                return(true);
            }

            return(SuffixStrategy.GetNextBooleanChoice(maxValue, out next));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns the next boolean choice.
 /// </summary>
 /// <param name="maxValue">The max value.</param>
 /// <param name="next">Next</param>
 /// <returns>Boolean</returns>
 public bool GetNextBooleanChoice(int maxValue, out bool next)
 {
     ++ScheduledSteps;
     return(ChildStrategy.GetNextBooleanChoice(maxValue, out next));
 }