public void CreateQuestionDuplicator_RandomlySelectedQuestion_Throws()
        {
            var questionDuplicatorFactory = new QuestionDuplicatorFactory
                                            (
                dbContext: null
                                            );

            Assert.Throws <InvalidOperationException>
            (
                () => questionDuplicatorFactory.CreateQuestionDuplicator
                (
                    new RandomlySelectedQuestion()
                )
            );
        }
        public void CreateQuestionDuplicator_ReturnsCorrectType(
            Type questionType,
            Type expectedDuplicatorType)
        {
            var questionDuplicatorFactory = new QuestionDuplicatorFactory
                                            (
                dbContext: null
                                            );

            var result = questionDuplicatorFactory.CreateQuestionDuplicator
                         (
                (Question)Activator.CreateInstance(questionType)
                         );

            Assert.Equal(expectedDuplicatorType, result.GetType());
        }
Exemplo n.º 3
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public QuestionService(
			DatabaseContext dbContext, 
			QuestionLoaderFactory questionLoaderFactory, 
			QuestionUpdaterFactory questionUpdaterFactory,
			QuestionGraderFactory questionGraderFactory,
			QuestionDuplicatorFactory questionDuplicatorFactory,
			IQuestionGenerator questionGenerator,
			IJsonSerializer jsonSerializer,
			IRandomNumberProvider randomNumberProvider,
			ITimeProvider timeProvider)
		{
			_dbContext = dbContext;
			_questionLoaderFactory = questionLoaderFactory;
			_questionUpdaterFactory = questionUpdaterFactory;
			_questionGraderFactory = questionGraderFactory;
			_questionDuplicatorFactory = questionDuplicatorFactory;
			_questionGenerator = questionGenerator;
			_jsonSerializer = jsonSerializer;
			_randomNumberProvider = randomNumberProvider;
			_timeProvider = timeProvider;
		}
		/// <summary>
		/// Creates a question service.
		/// </summary>
		private QuestionService CreateQuestionService(
			DatabaseContext dbContext,
			QuestionLoaderFactory questionLoaderFactory = null,
			QuestionUpdaterFactory questionUpdaterFactory = null,
			QuestionGraderFactory questionGraderFactory = null,
			QuestionDuplicatorFactory questionDuplicatorFactory = null,
			IQuestionGenerator questionGenerator = null,
			IJsonSerializer jsonSerializer = null,
			IRandomNumberProvider randomNumberProvider = null,
			ITimeProvider timeProvider = null)
		{
			return new QuestionService
			(
				dbContext,
				questionLoaderFactory,
				questionUpdaterFactory,
				questionGraderFactory,
				questionDuplicatorFactory,
				questionGenerator,
				jsonSerializer,
				randomNumberProvider,
				timeProvider
			);
		}