コード例 #1
0
        public void GetAnswers_NoCookie()
        {
            // Arrange
            _fakeCookieContext.Setup(x => x.GetCookie(Constants.CookieName.Answers)).Returns((HttpCookie)null);

            // Act
            var result = _manager.GetAnswers();

            // Assert
            Assert.AreEqual(0, result.Count);
        }
コード例 #2
0
        private ActionResult ShowResult(OutcomeType expectedOutcomeType)
        {
            var referrer = _httpWrapper.UrlReferrer;

            if (referrer == null || !referrer.IsRouteMatch(_httpWrapper.HttpContext, MVC.Questions.Name, MVC.Questions.ActionNames.Index))
            {
                _answerManager.StoreAnswers(_httpWrapper.QueryString);
            }

            var answers   = _answerManager.GetAnswers();
            var questions = _questionManager.GetAllQuestions();

            if (answers.Count < questions.Count)
            {
                return(RedirectToAction(MVC.Home.Index()));
            }

            var dictionary = answers.ToDictionary(x => x.Key.Id, x => x.Value);

            var persona     = _personaManager.GetPersona(dictionary);
            var outcomeType = persona?.OutcomeType ?? OutcomeType.Unsure;

            if (outcomeType != expectedOutcomeType)
            {
                return(RedirectToOutcomeType(outcomeType));
            }

            var visitor     = new Visitor(outcomeType, persona?.Id, dictionary);
            var obligations = _obligationManager.GetObligationsForVisitor(visitor);

            return(View(MVC.Results.Views.ViewNames.Index, new ResultModel {
                Obligations = obligations, Answers = answers, OutcomeType = outcomeType
            }));
        }
コード例 #3
0
 public virtual ActionResult Warmup()
 {
     return(Json(new
     {
         Questions = _questionManager.GetAllQuestions().Count,
         Answers = _answerManager.GetAnswers().Count,
         Obligations = _obligationManager.GetAllObligations().Count,
         Personas = _personaManager.GetAllPersonas().Count
     }, JsonRequestBehavior.AllowGet));
 }
コード例 #4
0
        public virtual ActionResult Index(string id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var question = _questionManager.GetQuestion(id);

            if (question == null)
            {
                throw new ArgumentException(nameof(id));
            }

            if (question.QuestionNumber > _answerManager.GetAnswers().Count + 1)
            {
                return(RedirectToAction(MVC.Home.Index()));
            }

            question.Answer = _answerManager.RetrieveAnswerId(question.Id);
            return(View(question));
        }