Example #1
0
        public void Should_ReturnQuestionOrResult_When_TopicExist()
        {
            //Arrange
            var expectedResult = new QuestionModel
            {
                Keywords  = new string[] { "courses", "learn", "study" },
                Name      = "Searching .Net courses",
                Decisions = new List <DecisionModel>
                {
                    new DecisionModel
                    {
                        Answer    = "We have super hero course for you",
                        Meta      = new string[] { ".net", "1-2 hours", "novice" },
                        Resources = "epam.learn.com/super-hero/courses/web-api"
                    },
                    new DecisionModel
                    {
                        Answer    = "You are lucky! here is your course",
                        Meta      = new string[] { "Azure", "1 hour per day", "expert" },
                        Resources = "epam.learn.com/death-match/azure"
                    }
                },
                Questions = new List <Question>
                {
                    new Question
                    {
                        IsAnswered = "false",
                        Keywords   = new string[] { ".net", "java", "python" },
                        Text       = "What technology do you interested in?"
                    },
                    new Question
                    {
                        IsAnswered = "false",
                        Keywords   = new string[] { "1-2 hours", "3-5 hours", "6+ hours" },
                        Text       = "How much time are you ready to spend on study (per day)?"
                    },
                    new Question
                    {
                        IsAnswered = "false",
                        Keywords   = new string[] { "novice", "intermediate", "expert" },
                        Text       = "Select difficulty"
                    }
                }
            };

            //Act
            var actualResult = _decisionMaker.GetQuestionOrResult("courses");

            //Assert
            for (var i = 0; i < expectedResult.Decisions.Count; i++)
            {
                for (var j = 0; j < expectedResult.Decisions[i].Meta.Length; j++)
                {
                    Assert.AreEqual(expectedResult.Decisions[i].Meta[j], actualResult.Decisions[i].Meta[j]);
                }

                Assert.AreEqual(expectedResult.Decisions[i].Answer, actualResult.Decisions[i].Answer);
            }

            for (var i = 0; i < expectedResult.Questions.Count; i++)
            {
                for (var j = 0; j < expectedResult.Questions[i].Keywords.Length; j++)
                {
                    Assert.AreEqual(expectedResult.Questions[i].Keywords[j], actualResult.Questions[i].Keywords[j]);
                }

                Assert.AreEqual(expectedResult.Questions[i].Text, actualResult.Questions[i].Text);
            }
        }