Example #1
0
        public void TestGame_SubmitResponseForQuestionNotInCurrentQuizSection_ThrowsException()
        {
            // arrange
            var command = new SubmitInteractionResponseCommand
            {
                TeamId          = Game.TeamIds[0],
                ChoiceOptionIds = new List <int> {
                    3
                },
                InteractionId = 1,
                Response      = string.Empty,
                QuizItemId    = Quiz.QuizSections[2].QuestionItemRefs[0].Id
            };

            // act & assert
            var exception = Assert.ThrowsExceptionAsync <DomainException>(() => Mediator.Send(command)).Result;

            Assert.AreEqual(ResultCode.QuestionNotInCurrentQuizSection, exception.ResultCode);
            Assert.AreEqual("This question doesn't belong to the current quiz section.", exception.Message);
            Assert.IsTrue(exception.IsBadRequest);
        }
Example #2
0
        public void TestGame_SubmitResponseForInvalidQuestion_ThrowsException()
        {
            // arrange
            var command = new SubmitInteractionResponseCommand
            {
                TeamId          = Game.TeamIds[0],
                ChoiceOptionIds = new List <int> {
                    3
                },
                InteractionId = 1,
                Response      = string.Empty,
                QuizItemId    = Guid.Empty.ToShortGuidString()
            };

            // act & assert
            var exception = Assert.ThrowsExceptionAsync <DomainException>(() => Mediator.Send(command)).Result;

            Assert.AreEqual(ResultCode.InvalidEntityId, exception.ResultCode);
            Assert.AreEqual("Invalid QuizItemId.", exception.Message);
            Assert.IsTrue(exception.IsBadRequest);
        }