public TwiMLResult Create(
            [Bind(Include = "RecordingUrl,Digits,CallSid,From")]
            Answer answer)
        {
            _answersRepository.Create(answer);

            var nextQuestion = new QuestionFinder(_questionsRepository).FindNext(answer.QuestionId);
            var response = new Response(nextQuestion).Build();

            return TwiML(nextQuestion != null ? response : ExitResponse);
        }
        // GET: /questions/find/5
        public ActionResult Find(int id)
        {
            var question = _questionsRepository.Find(id);
            if (question == null)
            {
                return HttpNotFound();
            }

            var response = new Response(question).Build();
            return TwiML(response);
        }
        public void Build_a_response_using_Gather_if_the_question_type_is_Numeric_or_YesNo(
            int id, string body, QuestionType type)
        {
            var question = new Question { Id = id, Body = body, Type = type };
            var response = new Response(question).Build();
            var expectedResponse = string.Format(
                "<Response>\r\n" +
                "  <Say>{0}</Say>\r\n" +
                "  <Say>{1}</Say>\r\n" +
                "  <Gather action=\"/answers/create?questionId={2}\" />\r\n" +
                "</Response>", question.Body, Response.QuestionTypeToMessage[question.Type], question.Id);

            Assert.That(response.ToString(), Is.EqualTo(expectedResponse));
        }
        public void Build_a_response_using_Record_if_the_question_type_is_Voice()
        {
            var question = new Question
            {
                Id = 1,
                Body = "How's the weather?",
                Type = QuestionType.Voice
            };
            var response = new Response(question).Build();
            var expectedResponse = string.Format(
                "<Response>\r\n" +
                "  <Say>{0}</Say>\r\n" +
                "  <Say>{1}</Say>\r\n" +
                "  <Record action=\"/answers/create?questionId={2}\" />\r\n" +
                "</Response>", question.Body, Response.QuestionTypeToMessage[question.Type], question.Id);

            Assert.That(response.ToString(), Is.EqualTo(expectedResponse));
        }