public void GivenZeroQuestionsPerCategory_WheAskingQuestion_Throws(string category) { var generatorMock = new Mock <IQuestionService>(); generatorMock.Setup(g => g.Get()).Returns( new Dictionary <string, Queue <string> > { { QuestionCategory.Pop, new Queue <string>() }, { QuestionCategory.Rock, new Queue <string>() }, { QuestionCategory.Science, new Queue <string>() }, { QuestionCategory.Sports, new Queue <string>() } }); var provider = new QuestionProvider(generatorMock.Object); Assert.Throws <InvalidOperationException>(() => provider.GetQuestion(category)); }
public void GivenOneQuestionPerCategory_WhenAskingQuestion_CorrectQuestionIsReturned(string category) { var generator = new Mock <IQuestionService>(); generator.Setup(g => g.Get()).Returns( new Dictionary <string, Queue <string> > { { QuestionCategory.Pop, new Queue <string>(new[] { "QPop" }) }, { QuestionCategory.Rock, new Queue <string>(new[] { "QRock" }) }, { QuestionCategory.Science, new Queue <string>(new[] { "QScience" }) }, { QuestionCategory.Sports, new Queue <string>(new[] { "QSports" }) } }); var provider = new QuestionProvider(generator.Object); var question = provider.GetQuestion(category); Assert.That(question, Is.EqualTo("Q" + category)); }
public void GivenOneQuestionPerCategory_WhenAskingQuestion_QuestionContainerIsEmptied(string category) { var generator = new Mock <IQuestionService>(); generator.Setup(g => g.Get()).Returns( new Dictionary <string, Queue <string> > { { QuestionCategory.Pop, new Queue <string>(new[] { "QPop" }) }, { QuestionCategory.Rock, new Queue <string>(new[] { "QRock" }) }, { QuestionCategory.Science, new Queue <string>(new[] { "QScience" }) }, { QuestionCategory.Sports, new Queue <string>(new[] { "QSports" }) } }); var provider = new QuestionProvider(generator.Object); provider.GetQuestion(category); Assert.That(provider.GetQuestionCount(category), Is.Zero); }
public void GivenMultipleQuestionsPerCategory_AfterAskingQuestion_QuestionContainerDecreasesInSizeWithOne() { var generator = new Mock <IQuestionService>(); generator.Setup(g => g.Get()).Returns( new Dictionary <string, Queue <string> > { { QuestionCategory.Pop, new Queue <string>(new[] { "QPop1", "QPop2", "QPop3" }) }, { QuestionCategory.Rock, new Queue <string>(new[] { "QRock" }) }, { QuestionCategory.Science, new Queue <string>(new[] { "QScience" }) }, { QuestionCategory.Sports, new Queue <string>(new[] { "QSports" }) } }); var provider = new QuestionProvider(generator.Object); provider.GetQuestion(QuestionCategory.Pop); Assert.That(provider.GetQuestionCount(QuestionCategory.Pop), Is.EqualTo(2)); }