private void _ValidateDataAccess(IQuizDataAccess quizDataAccess) { if (quizDataAccess == null) { throw new ArgumentNullException("quizDataAccess"); } }
private void _PrepareMockedQuizDataAccess() { //prepare the repository's db dependency using the moq framework _MockingService = new Mock <IQuizDataAccess>(); var returnQuizList = PrepareTestQuizCollection(); //Setup the mock object to return a collection of quiz objects //when calling the GetAllQuizesFromDatabase method _MockingService .Setup <IEnumerable <Quiz> >(q => q.GetAllQuizesFromDatabase()) .Returns(returnQuizList); //Set the quiz sql data access to the mocked object reference //The IQuizDataAccess reference will return the Quiz list //that we've configured above. This allows us to test //the repository without depending on the database which //can't be relied on. _QuizSqlDataAccess = _MockingService.Object; }
public TopicRepository(IQuizDataAccess <Topic> dataAccess, IQuizCache <Topic> quizCache) { _quizDataAccess = dataAccess; _quizCache = quizCache; }
/// <summary> /// QuizRepository constructor /// that allows dependency injection /// upon instantiation. /// </summary> /// <param name="quizDataAccess"> /// A reference to the IQuizDataAccess /// dependency that provides /// access to the database. /// </param> public QuizRepository(IQuizDataAccess quizDataAccess) { _ValidateDataAccess(quizDataAccess); this._QuizDataAccess = quizDataAccess; }
public QuestionRepository(IQuizDataAccess <Question> quizDataAccess, IQuizCache <Question> cache) { _quizDataAccess = quizDataAccess; _quizCache = cache; }
public AnswerRepository(IQuizDataAccess <Answer> quizDataAccess, IQuizCache <Answer> cache) { _quizDataAccess = quizDataAccess; _cache = cache; }