public static void AssertStep(StoryStep <IMessageActivity> storyStep, PerformanceStep <IMessageActivity> performanceStep, string[] options = null)
        {
            switch (storyStep.Actor)
            {
            case Actor.Bot:
                AssertBotStepMessage(storyStep, performanceStep);
                break;

            case Actor.User:
                AssertUserStepMessage(storyStep, performanceStep, options);
                break;
            }
        }
示例#2
0
        private static void AssertBotStepMessage(StoryStep storyStep, PerformanceStep performanceStep)
        {
            var message = performanceStep.MessageActivity;
            var frame   = storyStep.StoryFrame;

            switch (frame.ComparisonType)
            {
            case ComparisonType.TextExact:
                ProcessFrameTextExact(frame, performanceStep.MessageActivity.Type, performanceStep.Message);
                break;

            case ComparisonType.TextMatchRegex:
                ProcessBotFrameTextMatchRegex(frame, message);
                break;

            case ComparisonType.AttachmentListPresent:
                ProcessBotFrameListPresent(frame, message);
                break;

            case ComparisonType.TextExactWithSuggestions:
                ProcessBotFrameTextWithSuggestions(frame, message);
                break;

            case ComparisonType.TextMatchRegexWithSuggestions:
                ProcessBotFrameTextMatchRegexWithSuggestions(frame, message);
                break;

            case ComparisonType.Predicate:
                ProcessBotFramePredicate(frame, message);
                break;

            default:
                var reasonMessage = string.Format(
                    CultureInfo.InvariantCulture,
                    "Comparison type {0} is not supported for bot frame.",
                    frame.ComparisonType);

                throw new ArgumentOutOfRangeException(nameof(frame.ComparisonType), reasonMessage);
            }
        }
示例#3
0
        private static void AssertUserStepMessage(StoryStep storyStep, PerformanceStep performanceStep, string[] options = null)
        {
            var frame = storyStep.StoryFrame;

            switch (frame.ComparisonType)
            {
            case ComparisonType.TextExact:
                ProcessFrameTextExact(frame, performanceStep.MessageActivity.Type, performanceStep.Message);
                break;

            case ComparisonType.Option:
                AssertUserFrameOption(frame, performanceStep.MessageActivity, options);
                break;

            default:
                var reasonMessage = string.Format(
                    CultureInfo.InvariantCulture,
                    "Comparison type {0} is not supported for user frame.",
                    frame.ComparisonType);

                throw new ArgumentOutOfRangeException(nameof(frame.ComparisonType), reasonMessage);
            }
        }
        public static void AddNotNullStep <T>(this List <PerformanceStep <T> > performanceSteps, PerformanceStep <T> performanceStep)
        {
            if (performanceStep != null)
            {
                performanceStep.StepIndex = performanceSteps.Count;

                performanceSteps.Add(performanceStep);
            }
        }