public AnswerDTO Get(int ID)
        {
            AnswerEntity getanswer = ur.Get(ID);
            AnswerDTO    answer    = Mapper.Map <AnswerDTO>(getanswer);

            return(answer);
        }
        public void A_ChangedAnswer_modifies_Existing_Answer_in_the_database()
        {
            var bootStrapper = new BootStrapper();
            bootStrapper.StartServices();
            var serviceEvents = bootStrapper.GetService<IServiceEvents>();
            //1.- Create message
            var aggr = GenerateRandomAggregate();

            //2.- Create the tuple in the database
            var repository = new AnswerRepository(_configuration.TestServer);
            repository.Insert(aggr);

            //3.- Change the aggregate
            aggr.PersonId = Guid.NewGuid();
            aggr.AnswerValues.ToList().ForEach(v => v.Type = new Random().Next());

            //4.- Emit message
            var message = GenerateMessage(aggr);
            message.MessageType = typeof(ChangedAnswer).Name;
            serviceEvents.AddIncommingEvent(new IncommingEvent { @event = message });

            //5.- Load the saved country
            var country = repository.Get(aggr.Id);
            //6.- Check equality
            Assert.True(ObjectExtension.AreEqual(aggr, country));
            
        }
        public void GetTest()
        {
            var data = repository.Get("538359db10fb8e1248981698");

            //Xunit.Assert.NotNull(data);
            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(data);

            //Xunit.Assert.True(data.Count() > 0);
            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(data.AnswerText.Equals("Jahirul Islam"));
        }
 public void A_RegisteredAnswer_creates_a_new_answer_in_the_database()
 {
     var bootStrapper = new BootStrapper();
     bootStrapper.StartServices();
     var serviceEvents = bootStrapper.GetService<IServiceEvents>();
     //1.- Create message
     var aggr = GenerateRandomAggregate();
     var message = GenerateMessage(aggr);
     //2.- Emit message
     serviceEvents.AddIncommingEvent(new IncommingEvent { @event = message });
     //3.- Load the saved country
     var repository = new AnswerRepository(_configuration.TestServer);
     var country = repository.Get(aggr.Id);
     //4.- Check equality
     Assert.True(ObjectExtension.AreEqual(aggr, country));
 }
        public void ArchiveAnswer_Correct()
        {
            var options = new DbContextOptionsBuilder <QAndAContext>().UseInMemoryDatabase(MethodBase.GetCurrentMethod().Name).Options;
            var context = new QAndAContext(options);
            IAnswerRepository   ARepo = new AnswerRepository(context);
            IQuestionRepository QRepo = new QuestionRepository(context);

            var question = new QuestionTO
            {
                Questioning  = "Not hungry",
                CreationDate = DateTime.Now,
                State        = State.Pending,
                IsArchived   = false,
                LostSoul     = new UserTO {
                    FirstName = "Don't wanna", LastName = "Eat"
                }
            };

            var addedQuestion = QRepo.Insert(question);

            QRepo.Save();

            var answer = new AnswerTO
            {
                Answering  = "must be the donuts",
                AnswerTime = DateTime.Now.AddHours(1),
                QuestionId = addedQuestion.Id,
                Savior     = new UserTO {
                    FirstName = "Any", LastName = "Officer"
                }
            };

            var addedAnswer = ARepo.Insert(answer);

            ARepo.Save();

            Assert.AreEqual(1, ARepo.GetAll().Count());

            var deletedAnswer = ARepo.Delete(addedAnswer);

            ARepo.Save();
            var all = ARepo.GetAll();

            Assert.AreEqual(0, all.Count());
            Assert.IsTrue(deletedAnswer);
            Assert.IsTrue(ARepo.Get(addedAnswer.Id).IsDeleted);
        }
Example #6
0
        public void UpdateAnswer_Correct()
        {
            var options = new DbContextOptionsBuilder <QAndAContext>().UseInMemoryDatabase(MethodBase.GetCurrentMethod().Name).Options;
            var context = new QAndAContext(options);
            IAnswerRepository   ARepo = new AnswerRepository(context);
            IQuestionRepository QRepo = new QuestionRepository(context);

            var question = new QuestionTO
            {
                Questioning  = "Maybe it's working",
                CreationDate = DateTime.Now,
                State        = State.Pending,
                IsArchived   = false,
                LostSoul     = new UserTO {
                    FirstName = "Call me", LastName = "Kevin"
                }
            };

            var addedQuestion = QRepo.Insert(question);

            QRepo.Save();

            var answer = new AnswerTO
            {
                Answering  = "No shit Sherlock",
                AnswerTime = DateTime.Now.AddHours(1),
                QuestionId = addedQuestion.Id,
                Savior     = new UserTO {
                    FirstName = "Dr", LastName = "Watson"
                }
            };

            var addedAnswer = ARepo.Insert(answer);

            ARepo.Save();

            addedAnswer.Answering = "Can't be right";
            var updatedAnswer = ARepo.Update(addedAnswer);

            ARepo.Save();

            Assert.AreEqual(1, ARepo.GetAll().Count());
            Assert.AreEqual(1, QRepo.Get(addedAnswer.QuestionId).Answers.Count());
            Assert.AreEqual("Can't be right", ARepo.Get(updatedAnswer.Id).Answering);
        }
        public void A_UnregisteredAnswer_removers_Existing_answer_in_the_database()
        {
            var bootStrapper = new BootStrapper();
            bootStrapper.StartServices();
            var serviceEvents = bootStrapper.GetService<IServiceEvents>();
            //1.- Create message
            var aggr = GenerateRandomAggregate();

            //2.- Create the tuple in the database
            var repository = new AnswerRepository(_configuration.TestServer);
            repository.Insert(aggr);

            //2.- Emit message
            var message = GenerateMessage(aggr);
            message.MessageType = typeof(UnregisteredAnswer).Name;
            serviceEvents.AddIncommingEvent(new IncommingEvent { @event = message });

            var country = repository.Get(aggr.Id);
            Assert.Null(country);
            
        }
Example #8
0
        public Answer Get(int id)
        {
            var exam = AnswerRepository.Get(id);

            return(exam);
        }