Beispiel #1
0
 public QuestionController()
 {
     _manager             = new QuestionManager(Repository, UnitOfWork);
     _alternativeManager  = new AlternativeManager(new NHibernateRepository <Alternative>(UnitOfWork), UnitOfWork);
     _sendQuestionManager = new SendQuestionManager(new NHibernateRepository <UserQuestion>(UnitOfWork), UnitOfWork);
     _subscribeManager    = new SubscribeManager(new NHibernateRepository <Subscription>(UnitOfWork), UnitOfWork);
 }
        public IHttpActionResult Post(Alternative alternative)
        {
            var alternativeManager  = new AlternativeManager(new NHibernateRepository <Alternative>(UnitOfWork), UnitOfWork);
            var sendQuestionManager = new SendQuestionManager(new NHibernateRepository <UserQuestion>(UnitOfWork), UnitOfWork);
            var result   = _manager.Reply(alternative.Id, this.GetUser(), alternativeManager, sendQuestionManager);
            var response = result ? "Você acertou. Parabéns!" : "Resposta errada! Não desanime, continue estudando.";

            return(Ok(response));
        }
Beispiel #3
0
 public UserQuestionController()
 {
     _manager            = new SendQuestionManager(Repository, UnitOfWork);
     _alternativeManager = new AlternativeManager(new NHibernateRepository <Alternative>(UnitOfWork), UnitOfWork);
 }
Beispiel #4
0
        public void Initialize()
        {
            _mockRepository = new Mock <IRepository <Question> >();
            _mockUnitOfWork = new Mock <IUnitOfWork>();
            _manager        = new QuestionManager(_mockRepository.Object, _mockUnitOfWork.Object);


            var unitOfWorkAlternative = new Mock <IUnitOfWork>();

            _mockAlternative    = new Mock <IRepository <Alternative> >();
            _alternativeManager = new AlternativeManager(_mockAlternative.Object, unitOfWorkAlternative.Object);

            var unitOfWorkSendQuestion = new Mock <IUnitOfWork>();

            _mockUserQuestion    = new Mock <IRepository <UserQuestion> >();
            _sendQuestionManager = new SendQuestionManager(_mockUserQuestion.Object, unitOfWorkSendQuestion.Object);

            _mockSubscribe = new Mock <IRepository <Subscription> >();
            var unitOfWorkSubscribe = new Mock <IUnitOfWork>();

            _subscribeManager = new SubscribeManager(_mockSubscribe.Object, _mockUnitOfWork.Object);

            _teacher = new User()
            {
                Id = 1, IsTeacher = true, Name = "Professor"
            };
            _course = new Course()
            {
                Description = "Testes",
                Name        = "Matematica",
                Id          = 1,
                Created     = new DateTime(2016, 01, 01),
                Teacher     = _teacher
            };

            _question = new Question
            {
                Id          = 1,
                Course      = _course,
                Description = "Quanto é 1 + 1"
            };

            _alternatives = new List <Alternative>();
            for (int i = 0; i < 10; i++)
            {
                _alternatives.Add(new Alternative()
                {
                    Question    = _question,
                    Description = " teste numero " + 1,
                    IsCorrect   = false,
                    Order       = i
                });
            }

            _alternatives.Add(new Alternative()
            {
                Question    = _question,
                Description = " teste numero " + _alternatives.Count,
                IsCorrect   = true,
                Order       = _alternatives.Count
            });
        }