Example #1
0
        public void CreateHiraganaQuiz_OutOfRange_Test(byte nbAnwsers)
        {
            // Arrange
            var kanaRepository = Substitute.For <IKanaRepository>();

            kanaRepository.GetAllByType(Arg.Any <KanaType>()).Returns(_hiraganas);
            kanaRepository.CountByType(Arg.Any <KanaType>()).Returns((byte)_hiraganas.Count());

            // Act
            var quizFactory = new QuizFactory(kanaRepository);

            // Assert
            Assert.Throws <KanaQuizException>(() => quizFactory.CreateHiraganaQuiz(nbAnwsers));
        }
Example #2
0
        public void CreateHiraganaQuiz_Test(byte nbAnwsers)
        {
            // Arrange
            var kanaRepository = Substitute.For <IKanaRepository>();

            kanaRepository.GetAllByType(Arg.Any <KanaType>()).Returns(_hiraganas);
            kanaRepository.CountByType(Arg.Any <KanaType>()).Returns((byte)_hiraganas.Count());

            // Act
            var quizFactory = new QuizFactory(kanaRepository);
            var result      = quizFactory.CreateHiraganaQuiz(nbAnwsers);

            // Assert
            Assert.Equal(nbAnwsers, result.Answers.Count());
            Assert.Equal(KanaType.Hiragana, result.Type);
            Assert.Contains(result.GoodAnswer, result.Answers);
        }