public void Provided_Wrong_Answer_Should_Throw_Exception()
        {
            var dict = CreateFormCollection(new Dictionary <string, StringValues> {
                ["random-question-id"] = "2", ["random-question"] = "2"
            });

            Assert.Throws <InvalidOperationException>(() => RandomQuestionService.ValidateProvidedAnswer(dict));
        }
        public void Form_Missing_RandomQuestionIdField_Should_Throw_Exception()
        {
            var dict = CreateFormCollection(new Dictionary <string, StringValues> {
                ["email"] = "*****@*****.**", ["random-question"] = "2"
            });

            Assert.Throws <InvalidOperationException>(() => RandomQuestionService.ValidateProvidedAnswer(dict));
        }
        public void Empty_Form_Should_Throw_Exception()
        {
            var emptyForm = CreateEmptyForm();

            Assert.Throws <ArgumentNullException>(() => RandomQuestionService.ValidateProvidedAnswer(emptyForm));

            IFormCollection CreateEmptyForm() => new FormCollection(new Dictionary <string, StringValues>());
        }
        public void Provided_Correct_Answer_Should_BeOk()
        {
            var dict = CreateFormCollection(new Dictionary <string, StringValues> {
                ["random-question-id"] = "2", ["random-question"] = "1"
            });
            var result = RandomQuestionService.ValidateProvidedAnswer(dict);

            Assert.True(result);
        }
 public RandomQuestionService_ValidateProvidedAnswerTests()
 {
     // this is to create the json
     try
     {
         var dict = CreateFormCollection(new Dictionary <string, StringValues> {
             ["random-question-id"] = "2", ["random-question"] = "1"
         });
         var result = RandomQuestionService.ValidateProvidedAnswer(dict);
     }
     catch
     {
     }
 }
        private bool IsProvidedAnswerCorrect(string questionId, string providedAnswer)
        {
            var result = RandomQuestionService.ValidateProvidedAnswer(questionId, providedAnswer);

            return(result);
        }
 public void Missing_Form_Should_Throw_Exception()
 {
     Assert.Throws <ArgumentNullException>(() => RandomQuestionService.ValidateProvidedAnswer(null));
 }