示例#1
0
        private void CreateServices()
        {
            QuizService         = new QuizService(QuizRepo, QuizRatingRepo);
            QuestionService     = new QuestionService(QuestionRepo);
            AnswerService       = new AnswerService(AnswerRepo);
            QuizCategoryService = new QuizCategoryService(QuizCategoryRepo);
            QuizResultService   = new QuizResultService(QuizRepo, QuizResultRepo, QuizRatingRepo, QuestionRepo, AnswerRepo);
            UserActivityService = new UserActivityService(UserActivityRepo, QuizRepo, QuestionRepo);


            ModelConverter = new ModelConverter(
                QuizCategoryService, QuizResultService, AnswerService, QuestionService, QuizService);
            ViewModelConverter = new ViewModelConverter(
                QuizService, AnswerService, QuestionService, QuizCategoryService);
        }
        public void Setup()
        {
            var questions = new List <Question>()
            {
                new Question(_question1Id, "", new List <QuestionAnswer>()
                {
                    new QuestionAnswer(_answer1Id, "", true)
                }),
                new Question(_question2Id, "", new List <QuestionAnswer>()
                {
                    new QuestionAnswer(_answer2Id, "", true)
                }),
                new Question(_question3Id, "", new List <QuestionAnswer>()
                {
                    new QuestionAnswer(_answer3Id, "", true)
                }),
                new Question(_question4Id, "", new List <QuestionAnswer>()
                {
                    new QuestionAnswer(_answer4Id, "", true)
                }),
            };

            var questionRepo = Substitute.For <IQuestionRepository>();

            questionRepo.GetAll(Arg.Any <List <Guid> >()).ReturnsForAnyArgs(questions);

            var quizRepo = Substitute.For <IQuizRepository>();

            quizRepo.GetAll().ReturnsForAnyArgs(new List <Quiz>()
            {
                new Quiz("Carlos", 50),
                new Quiz("Gabriela", 50),
                new Quiz("Enrico", 100),
            });

            var validator = new FinishQuizCommandValidator();

            _service = new QuizResultService(quizRepo, questionRepo, validator);
        }