public async Task testcreateUserDialog()
        {
            var res = await sendBot("היי");

            Assert.IsTrue(res.Count == 3);
            res = await sendBot("לא בא לי להגיד לך");

            AssertNLP.contains(res, DBbotPhrase(Pkey.MissingUserInfo));
            res = await sendBot("יוחאי");

            AssertNLP.contains(res, DBbotPhrase(Pkey.LetsStart));

            res = await sendBot("מגדר זה רק אשלייה", "אתה יודע");

            AssertNLP.contains(res, DBbotPhrase(Pkey.MissingUserInfo));
            res = await sendBot("בן");

            AssertNLP.contains(res, DBbotPhrase(Pkey.ok));
            res = await sendBot("אני לומד באוניברסיטה של החיים", "ברחוב");

            AssertNLP.contains(res, DBbotPhrase(Pkey.MissingUserInfo));
            res = await sendBot("יא");

            AssertNLP.contains(res, DBbotPhrase(Pkey.ok));
            AssertNLP.contains(res, DBbotPhrase(Pkey.letsLearn));
        }
        public async Task testGetUserStatistics()
        {
            var newUser  = "******";
            var response = await createUser("יוחאי", "בן", "יא'", newUser);

            AssertNLP.contains(response, DBbotPhrase(Pkey.MainMenuText));
            AssertNLP.contains(response, DBbotPhrase(Pkey.MenuLearn));
            AssertNLP.contains(response, DBbotPhrase(Pkey.MenuNotLearn));

            var options = getOptions(response[1]);

            //good - statistic unknown user
            var res = await sendBot(options[3], true, newUser);

            AssertNLP.contains(res, DBbotPhrase(Pkey.notEnoughAnswersForStat));

            response = await createUser("יוחאי", "בן", "יא'");

            options = getOptions(response[1]);

            //good - statistic unknown user
            res = await sendBot(options[3]);

            AssertNLP.contains(res, DBbotPhrase(Pkey.userStatistics));
        }
        public async Task testLearningSpecialValues()
        {
            var db = new DataBaseController();

            var optionsRes = await getToLearningMenu();

            AssertNLP.contains(optionsRes, DBbotPhrase(Pkey.chooseStudyUnits));

            var allCategory = db.getAllCategory();
            var category    = allCategory[rand.Next(allCategory.Length)];
            var res         = await sendBot(category);

            res = await sendBot("ספר לי משהו מצחיק");

            AssertNLP.contains(res, DBbotPhrase(Pkey.mightHaveSomthing));
            res = await sendBot("ספר לי משהו מעניין");

            AssertNLP.contains(res, DBbotPhrase(Pkey.mightHaveSomthing));
            res = await sendBot("לך תזדיין");

            AssertNLP.contains(res, DBbotPhrase(Pkey.swearResponse));
            res = await sendBot("בן זונה");

            AssertNLP.contains(res, DBbotPhrase(Pkey.swearResponse));
            res = await sendBot("שרמוטה");

            AssertNLP.contains(res, DBbotPhrase(Pkey.swearSuspention));
            res = await sendBot("טוב בא נמשיך");

            AssertNLP.contains(res, DBbotPhrase(Pkey.duringSwearSuspention));
            res = await sendBot("סליחה");

            AssertNLP.contains(res, DBbotPhrase(Pkey.letsContinue));
        }
Esempio n. 4
0
        private async Task <List <string> > sendSwear()
        {
            var res = await sendBot("בן זונה");

            AssertNLP.contains(res, DBbotPhrase(Pkey.swearResponse));
            return(res);
        }
Esempio n. 5
0
        private async Task <List <string> > sendInfoRequest()
        {
            var res = await sendBot("תספר לי משהו מעניין");

            AssertNLP.contains(res, DBbotPhrase(Pkey.mightHaveSomthing));
            return(res);
        }
Esempio n. 6
0
        public void TestInitializeAttribute()
        {
            var task     = sendMessage("/deleteprofile");
            var response = task;

            AssertNLP.contains(response, "User profile deleted!");
        }
        public void deleteProfile()
        {
            var task     = sendMessage("/deleteprofile");
            var response = task;

            response.Wait();
            AssertNLP.contains(response.Result, "User profile deleted!");
        }
        public async Task testDeleteProfileDialog()
        {
            createUser("יוחאי", "בן", "יא");

            var response = await sendBot("/deleteprofile");

            AssertNLP.contains(response, "User profile deleted!");
            response = await sendBot("היי");

            AssertNLP.contains(response, DBbotPhrase(Pkey.NewUserGetName));
        }
Esempio n. 9
0
        private async Task <List <string> > RandomCreateAccount()
        {
            var res = await sendBot(randomAnswer());

            if (rand.Next(2) == 0)
            {
                res = await sendBot("יוחאי");
            }
            else
            {
                res = await sendBot(randomAnswer());

                res = await sendBot("יוחאי");
            }

            if (rand.Next(2) == 0)
            {
                res = await sendBot(randomAnswer());

                res = await sendBot("בן");
            }
            else
            {
                res = await sendBot("בת");
            }


            if (rand.Next(2) == 0)
            {
                //res = await sendBot(randomAnswer());

                res = await sendBot("י");
            }
            else if (rand.Next(2) == 0)
            {
                res = await sendBot(randomAnswer());

                res = await sendBot("יב");
            }
            else
            {
                res = await sendBot("יא");
            }

            AssertNLP.contains(res, DBbotPhrase(Pkey.ok));

            return(res);
        }
Esempio n. 10
0
        private async Task <List <string> > LearningMenu(List <string> res)
        {
            AssertNLP.contains(res, DBbotPhrase(Pkey.areUReaddyToLearn));
            var categories = db.getAllCategory();

            foreach (var c in categories)
            {
                AssertNLP.contains(res, c);
            }

            res = await sendBot(categories[rand.Next(categories.Length)]);

            AssertNLP.contains(res, DBbotPhrase(Pkey.letsLearn));
            res = await answerQuestion(res);

            return(res);
        }
Esempio n. 11
0
        public void testLearningMenuStopSession()
        {
            var db = new DataBaseController();

            var res = getToLearningMenu();

            AssertNLP.contains(res, DBbotPhrase(Pkey.chooseStudyUnits));
            var options = getOptions(res[1]);

            res = sendBot("תשובה כלשהי");
            res = sendBot("מספיק");
            AssertNLP.contains(res, DBbotPhrase(Pkey.earlyDiparture));
            AssertNLP.contains(res, DBbotPhrase(Pkey.areYouSure));
            res = sendBot("כן");
            AssertNLP.contains(res, DBbotPhrase(Pkey.goodbye));
            res = sendBot("בי");
            Assert.AreEqual(res, new string[] { });
        }
Esempio n. 12
0
        private async Task <List <string> > chooseMainMenu(List <string> res)
        {
            var options = getOptions(res[res.Count - 1]);

            if (rand.Next(2) == 0)
            {
                res = await sendBot(options[0]);

                AssertNLP.contains(res, DBbotPhrase(Pkey.NotImplamented));
                res = await chooseMainMenu(res);
            }
            else if (rand.Next(2) == 0)
            {
                res = await sendBot(options[1]);

                AssertNLP.contains(res, DBbotPhrase(Pkey.letsLearn));
                res = await LearningMenu(res);
            }
            else if (rand.Next(2) == 0)
            {
                res = await sendBot(options[3]);

                AssertNLP.contains(res, DBbotPhrase(Pkey.userStatistics));
                res = await chooseMainMenu(res);
            }
            else if (rand.Next(2) == 0)
            {
                res = await randomRequest();
                await chooseMainMenu(res);

                res = await chooseMainMenu(res);
            }
            else
            {
                res = await sendBot(randomAnswer());

                AssertNLP.contains(res, DBbotPhrase(Pkey.NotAnOption));
                res = await chooseMainMenu(res);
            }

            return(res);
        }
Esempio n. 13
0
        public async Task testGreetingDialog()
        {
            var res = await getToLearningMenu();

            res = await sendBot("לאומיות");

            res = await sendBot("טוב ביי");

            res = await sendBot("כן");

            AssertNLP.contains(res, DBbotPhrase(Pkey.goodbye));
            res = await sendBot("להתראות");

            Assert.IsTrue(res.Count == 0);
            res = await sendBot("ארוואר");

            res = await sendBot("היי");

            AssertNLP.contains(res, DBbotPhrase(Pkey.shortHello));
        }
Esempio n. 14
0
        private async Task <List <string> > trySwear(List <string> res)
        {
            res = await sendBot("לך תזדיין");

            AssertNLP.contains(res, DBbotPhrase(Pkey.swearResponse));

            res = await sendBot("ילד מטומטם");

            AssertNLP.contains(res, DBbotPhrase(Pkey.swearResponse));

            res = await sendBot("בן שרמוטה");

            AssertNLP.contains(res, DBbotPhrase(Pkey.swearResponse));
            AssertNLP.contains(res, DBbotPhrase(Pkey.swearSuspention));

            res = await sendBot("וןב בא נמשיך");

            AssertNLP.contains(res, DBbotPhrase(Pkey.duringSwearSuspention));

            res = await sendBot("סליחה");

            AssertNLP.contains(res, DBbotPhrase(Pkey.letsContinue));
            return(res);
        }
        public async void testMenuFreeText()
        {
            var response = await createUser("יוחאי", "בן", "יא'");

            AssertNLP.contains(response, DBbotPhrase(Pkey.MainMenuText));
            AssertNLP.contains(response, DBbotPhrase(Pkey.MenuLearn));
            AssertNLP.contains(response, DBbotPhrase(Pkey.MenuNotLearn));

            var options = getOptions(response[2]);
            //bad - try not learn
            var res = await sendBot("בא לי ללכת לבריכה");

            AssertNLP.contains(res, DBbotPhrase(Pkey.NotImplamented));

            //ugly
            res = await sendBot("משהו שלא נמצא בתפריט");

            AssertNLP.contains(res, DBbotPhrase(Pkey.NotAnOption));

            //good - lets learn
            res = await sendBot("קדימה בוא נלמד");

            AssertNLP.contains(res, DBbotPhrase(Pkey.letsLearn));
        }
Esempio n. 16
0
        public async Task testMainDialogTest()
        {
            var response = await createUser("יוחאי", "בן", "יא'");

            AssertNLP.contains(response, DBbotPhrase(Pkey.MainMenuText));
            AssertNLP.contains(response, DBbotPhrase(Pkey.MenuLearn));
            AssertNLP.contains(response, DBbotPhrase(Pkey.MenuNotLearn));

            var options = getOptions(response[2]);
            //bad - try not learn
            var res = await sendBot(options[1]);

            AssertNLP.contains(res, DBbotPhrase(Pkey.NotImplamented));

            //ugly
            res = await sendBot("משהו שלא נמצא בתפריט");

            AssertNLP.contains(res, DBbotPhrase(Pkey.NotAnOption));

            //good - lets learn
            res = await sendBot(options[0]);

            AssertNLP.contains(res, DBbotPhrase(Pkey.letsLearn));
        }
Esempio n. 17
0
        private async Task <List <string> > answerQuestion(List <string> res)
        {
            try
            {
                AssertNLP.contains(res, DBbotPhrase(Pkey.suggestBreak));
                if (rand.Next(2) == 0)
                {
                    res = await sendBot("כן");

                    return(res);
                }
                else
                {
                    res = await sendBot("לא");

                    AssertNLP.contains(res, DBbotPhrase(Pkey.letsContinueWitoutBreak));
                }
            }
            catch (Exception ex)
            {
            }

            if (rand.Next(2) == 0)
            {
                res = await randomRequest();

                AssertNLP.contains(res, DBbotPhrase(Pkey.letsContinue));
                res = await answerQuestion(res);
            }
            else if (rand.Next(2) == 0)
            {
                res = await sendBot("מספיק");

                AssertNLP.contains(res, DBbotPhrase(Pkey.stopLearningSession));
                if (rand.Next(2) == 0)
                {
                    res = await sendBot("כן");

                    res = await chooseMainMenu(res);
                }
                else
                {
                    res = await sendBot("לא");

                    res = await answerQuestion(res);
                }
            }
            else if (rand.Next(2) == 0)
            {
                res = await sendBot("תפריט ראשי");

                AssertNLP.contains(res, DBbotPhrase(Pkey.areYouSureMenu));
                if (rand.Next(2) == 0)
                {
                    res = await sendBot("כן");

                    res = await LearningMenu(res);
                }
                else
                {
                    res = await sendBot("לא");

                    res = await answerQuestion(res);
                }
            }
            else if (rand.Next(2) == 0)
            {
                res = await trySwear(res);
            }
            else
            {
                res = await sendBot(randomAnswer());

                AssertNLP.contains(res, DBbotPhrase(Pkey.wrongAnswer));
                return(await answerQuestion(res));
            }

            return(res);
        }
Esempio n. 18
0
        public void testLearningMenu()
        {
            var db = new DataBaseController();

            var optionsRes = getToLearningMenu();

            AssertNLP.contains(optionsRes, DBbotPhrase(Pkey.chooseStudyUnits));



            foreach (var category in db.getAllCategory())
            {
                //subject is avialabale

                AssertNLP.contains(optionsRes, category);

                //bad - try somthing else
                var res = sendBot("ביולוגיה");
                AssertNLP.contains(res, DBbotPhrase(Pkey.NotAnOption));

                //ugly
                res = sendBot("");
                AssertNLP.contains(res, DBbotPhrase(Pkey.NotAnOption));

                //good - lets learn
                res = sendBot(category);
                AssertNLP.contains(res, DBbotPhrase(Pkey.letsLearn));
                AssertNLP.contains(res, DBbotPhrase(Pkey.firstQuestion));



                var questions = new DataBaseController().getQuestion(category);
                Debug.WriteLine(category);
                Debug.WriteLine(questions.Length);



                var questionIdx = 0;
                for (; questionIdx < res.Count; questionIdx++)
                {
                    if (AssertNLP.contains(res[questionIdx], DBbotPhrase(Pkey.beforAskQuestion)[0]) || AssertNLP.contains(res[questionIdx], DBbotPhrase(Pkey.firstQuestion)[0]))
                    {
                        break;
                    }
                }

                var questionOpt = new List <IQuestion>(questions).FindAll(x => res[questionIdx].Contains(x.QuestionText));
                Assert.AreEqual(questionOpt.Count, 1);
                var question = questionOpt[0];

                Assert.AreEqual(question.Category, category);

                var counter = 0;
                foreach (var subQuestion in question.SubQuestion)
                {
                    AssertNLP.contains(res, subQuestion.questionText);

                    var rnd = r.Next(5);
                    switch (rnd)
                    {
                    case 0:
                        res = sendBot("הפסקה");
                        AssertNLP.contains(res, DBbotPhrase(Pkey.suggestBreak));
                        AssertNLP.contains(res, DBbotPhrase(Pkey.ok));
                        AssertNLP.contains(res, DBbotPhrase(Pkey.imWaiting));
                        res = sendBot("חזרתי");
                        AssertNLP.contains(res, DBbotPhrase(Pkey.letsContinue));
                        AssertNLP.contains(res, subQuestion.questionText);
                        break;

                    case 1:
                        res = sendBot("מספיק");
                        AssertNLP.contains(res, DBbotPhrase(Pkey.earlyDiparture));
                        AssertNLP.contains(res, DBbotPhrase(Pkey.areYouSure));
                        res = sendBot("לא");
                        AssertNLP.contains(res, DBbotPhrase(Pkey.keepLearning));
                        AssertNLP.contains(res, subQuestion.questionText);
                        break;

                    default:
                        break;
                    }

                    res = sendBot(subQuestion.answerText);

                    AssertNLP.contains(res, DBbotPhrase(Pkey.veryGood));

                    if (counter < 3)
                    {
                        AssertNLP.contains(res, DBbotPhrase(Pkey.moveToNextSubQuestion));
                    }
                    else
                    {
                        AssertNLP.contains(res, DBbotPhrase(Pkey.suggestBreak));
                        res = sendBot("לא");
                        AssertNLP.contains(res, DBbotPhrase(Pkey.ok));
                        AssertNLP.contains(res, DBbotPhrase(Pkey.moveToNextSubQuestion));
                    }
                }

                AssertNLP.contains(res, DBbotPhrase(Pkey.SubjectNotAvialable));
                res = sendBot("כן");
            }
        }
Esempio n. 19
0
        public void endOfSessionIntegrationTest()
        {
            var ss = new StudySession();

            Question1.AnswerScore = 100;
            Question2.AnswerScore = 90;
            Question3.AnswerScore = 80;

            ss.QuestionAsked.Add(Question1);
            ss.QuestionAsked.Add(Question2);
            ss.QuestionAsked.Add(Question3);

            ConvCtrl = new ConversationController(new User(), ss);


            //good

            AssertNLP.contains(ConvCtrl.endOfSession(), DBbotPhrase(Pkey.goodSessionEnd));


            ss = new StudySession();
            Question1.AnswerScore = 45;
            Question2.AnswerScore = 34;
            Question3.AnswerScore = 12;

            ss.QuestionAsked.Add(Question1);
            ss.QuestionAsked.Add(Question2);
            ss.QuestionAsked.Add(Question3);

            ConvCtrl = new ConversationController(new User(), ss);

            //bad
            AssertNLP.contains(ConvCtrl.endOfSession(), DBbotPhrase(Pkey.badSessionEnd));


            ss = new StudySession();
            Question1.AnswerScore = 45;
            Question2.AnswerScore = 34;


            ss.QuestionAsked.Add(Question1);
            ss.QuestionAsked.Add(Question2);


            ConvCtrl = new ConversationController(new User(), ss);

            AssertNLP.contains(ConvCtrl.endOfSession(), DBbotPhrase(Pkey.earlyDiparture));



            ss = new StudySession();


            ss.QuestionAsked.Add(Question1);
            ss.QuestionAsked.Add(Question2);
            ss.QuestionAsked.Add(Question3);

            ConvCtrl = new ConversationController(new User(), ss);//sad


            AssertNLP.contains(ConvCtrl.endOfSession(), DBbotPhrase(Pkey.badSessionEnd));
        }
        public async Task testLearningMenu()
        {
            var db = new DataBaseController();

            var optionsRes = await getToLearningMenu();

            AssertNLP.contains(optionsRes, DBbotPhrase(Pkey.chooseStudyUnits));

            var allCategory = db.getAllCategory();
            var category    = allCategory[rand.Next(allCategory.Length)];

            //subject is avialabale

            AssertNLP.contains(optionsRes, category);

            //bad - try somthing else
            var res = await sendBot("ביולוגיה");

            AssertNLP.contains(res, DBbotPhrase(Pkey.NotAnOption));

            //ugly
            //  res = await sendBot("");
            //  Assert.AreEqual(res.Count,0);

            //good - lets learn
            res = await sendBot(category);

            AssertNLP.contains(res, DBbotPhrase(Pkey.letsLearn));
            AssertNLP.contains(res, DBbotPhrase(Pkey.firstQuestion));



            var questions = new DataBaseController().getQuestion(category);

            Debug.WriteLine(category);
            Debug.WriteLine(questions.Length);



            List <IQuestion> questionOpt = null;

            foreach (var r in res)
            {
                questionOpt = new List <IQuestion>(questions).FindAll(x => r.Contains(x.QuestionText.Trim()));
                if (questionOpt.Count > 0)
                {
                    break;
                }
            }

            //  var questionOpt = new List<IQuestion>(questions).FindAll(x => AssertNLP.contains(res.ToArray(), x.QuestionText));
            Assert.AreEqual(questionOpt.Count, 1);
            var question = questionOpt[0];

            Assert.AreEqual(question.Category, category);

            var counter = 0;

            foreach (var subQuestion in question.SubQuestion)
            {
                AssertNLP.contains(res, subQuestion.questionText);

                var rnd = rand.Next(5);
                switch (rnd)
                {
                case 0:
                    res = await sendBot("הפסקה");

                    AssertNLP.contains(res, DBbotPhrase(Pkey.suggestBreak));
                    res = await sendBot("כן");

                    //AssertNLP.contains(res, DBbotPhrase(Pkey.ok));
                    AssertNLP.contains(res, DBbotPhrase(Pkey.imWaiting));
                    Thread.Sleep(10000);
                    res = await sendBot("חזרתי");

                    AssertNLP.contains(res, DBbotPhrase(Pkey.letsContinue));
                    AssertNLP.contains(res, subQuestion.questionText);
                    break;

                case 1:
                    res = await sendBot("מספיק");

                    AssertNLP.contains(res, DBbotPhrase(Pkey.earlyDiparture));
                    AssertNLP.contains(res, DBbotPhrase(Pkey.areYouSure));
                    res = await sendBot("לא");

                    AssertNLP.contains(res, DBbotPhrase(Pkey.keepLearning));
                    AssertNLP.contains(res, subQuestion.questionText);
                    break;

                default:
                    break;
                }

                res = await sendBot(subQuestion.answerText);

                AssertNLP.contains(res, DBbotPhrase(Pkey.veryGood));

                AssertNLP.contains(res, DBbotPhrase(Pkey.moveToNextSubQuestion));
            }
        }