Exemplo n.º 1
0
 /// <summary>
 /// Configure the BaseDialog.
 /// </summary>
 /// <param name="services">The bot services.</param>
 /// <param name="bot">The bot.</param>
 /// <param name="ID">The id of the dialog.</param>
 /// <param name="resetOnEnd">Indicator whether EndDialogAsync() shall automatically invoke Reset() </param>
 protected BaseDialog(S services, B bot, string ID, bool resetOnEnd = true) : base(ID)
 {
     BotServices      = services ?? throw new ArgumentNullException(nameof(services));
     TheBot           = bot == null ? throw new ArgumentNullException(nameof(bot)) : bot;
     ResponseAnalyzer = services.ResponseAnalyzer;
     QuestionAnalyzer = services.QuestionAnalyzer;
     _resetOnEnd      = resetOnEnd;
 }
Exemplo n.º 2
0
        public void Analyze_ShouldDetectDuplicateQuestionLabels()
        {
            var duplicateQuestionForm = new FormStatement("DuplicateQuestionForm", new List <Statement>
            {
                new QuestionStatement("duplicate", new StringValueType(), new StringLiteral("Sample")),
                new QuestionStatement("duplicate1", new StringValueType(), new StringLiteral("Sample")),
            });

            var questionAnalyzer = new QuestionAnalyzer();

            questionAnalyzer.Analyze(duplicateQuestionForm);
            Assert.NotEmpty(questionAnalyzer.Report.Warnings);
            Assert.Equal(1, questionAnalyzer.Report.Warnings.Count());
            Assert.IsType <DuplicateQuestionLabelMessage>(questionAnalyzer.Report.Warnings.FirstOrDefault());
        }
        /// <summary>
        /// Analyzes the specified path and extract all necessary info.
        /// </summary>
        /// <param name="path">The full path for the file to be analyzed.</param>
        /// <returns>
        ///     <c>FileInfo</c> object containing the extracted info.
        /// </returns>
        public FileInfo Analyze(string path)
        {
            this._FileReader = new FileReader();
            this._FileInfo   = new FileInfo();

            var fileContent = _FileReader.ReadLines(path);

            if (!string.IsNullOrEmpty(fileContent))
            {
                _FileInfo.ContentLines          = fileContent.Split('\n').ToList();
                _FileInfo.ValidLines            = ExtractValidLines();
                _FileInfo.ReferenceValues       = ExtractReferenceValues();
                _FileInfo.Questions             = ExtractQuestions();
                _FileInfo.HasInvalidExpressions = HasInvalidExpressions();

                this._AnswerMachine = new QuestionAnalyzer();
                _FileInfo.Output    = this._AnswerMachine.AnswerQuestions(_FileInfo);
            }

            return(_FileInfo);
        }