public void GetAllAnswersInCardBllTest() { // Arrange int cardId = this.cards[0].Id; this.mockQuiz.Setup( m => m.GetAllAnswersInCard(It.IsInRange <int>(1, 4, Range.Inclusive))) .Returns(this.answers); this.mockConverter .Setup(m => m.ConvertToAnswerListDTO(this.answers)) .Returns(this.answerDTOs); this.quiz = new QuizBll(this.mockQuiz.Object, this.mockConverter.Object); int expectedLength = this.answers.Count; int expectedfirstId = this.answers[0].Id; int expectedLastId = this.answers[3].Id; // Act int actualLength = this.quiz.GetAllAnswersInCard(cardId).ToList().Count(); int actualfirstId = this.quiz.GetAllAnswersInCard(cardId).ToList()[0].Id; int actualLastId = this.quiz.GetAllAnswersInCard(cardId).ToList()[3].Id; // Assert Assert.AreEqual(expectedLength, actualLength); Assert.AreEqual(expectedfirstId, actualfirstId); Assert.AreEqual(expectedLastId, actualLastId); }
public void GetAllAnswersInCardBllArgumentNullExceptionTest() { // Arrange List <Answer> nullAnswers = null; int cargId = 0; this.mockQuiz.Setup(m => m.GetAllAnswersInCard(cargId)).Returns(nullAnswers); this.mockConverter.Setup(m => m.ConvertToAnswerListDTO(this.answers)).Returns(this.answerDTOs); this.quiz = new QuizBll(this.mockQuiz.Object, this.mockConverter.Object); // act, accert Assert.Throws <ArgumentNullException>( () => this.quiz.GetAllAnswersInCard(cargId)); }
public void GetCardsByDeckBllTest() { // Arrange string deckName = this.decks[0].Name; List <Card> expected = this.cards; this.mockQuiz.Setup(m => m.GetCardsByDeck(deckName)).Returns(this.cards); this.mockConverter.Setup(m => m.ConvertToCardListDTO(this.cards)).Returns(this.cardDTOs); this.quiz = new QuizBll(this.mockQuiz.Object, this.mockConverter.Object); int expectedLength = this.cards.Count; int expectedfirstId = this.cards[0].Id; int expectedLastId = this.cards[1].Id; // Act int actualLength = this.quiz.GetCardsByDeck(deckName).ToList().Count(); int actualfirstId = this.quiz.GetCardsByDeck(deckName).ToList()[0].Id; int actualLastId = this.quiz.GetCardsByDeck(deckName).ToList()[1].Id; // Assert Assert.AreEqual(expectedLength, actualLength); Assert.AreEqual(expectedfirstId, actualfirstId); Assert.AreEqual(expectedLastId, actualLastId); }