public async Task TestAddQuestion()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "QAndATest").Options;
            var dbContext     = new ApplicationDbContext(options);
            var questionsRepo = new EfDeletableEntityRepository <Question>(dbContext);
            await questionsRepo.AddAsync(new Question { Id = "1", Text = "test" });

            var answersRepo = new EfDeletableEntityRepository <Answer>(dbContext);
            await answersRepo.AddAsync(new Answer { QuestionId = "1", Id = "2", Text = "testanswer" });

            var userManager           = TestUserManager <ApplicationUser>();
            var service               = new QuestionsAndAnswersService(questionsRepo, answersRepo);
            var controller            = new QuestionsAndAnswersController(service, userManager);
            var userMock              = new Mock <ClaimsPrincipal>();
            var controllerContextMock = new ControllerContext {
                HttpContext = new DefaultHttpContext {
                    User = userMock.Object
                },
            };

            controller.ControllerContext = controllerContextMock;

            var result = controller.AddQuestion();

            Assert.IsType <ViewResult>(result);
        }
        public async Task QAndA()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "QAndATest").Options;
            var dbContext     = new ApplicationDbContext(options);
            var questionsRepo = new EfDeletableEntityRepository <Question>(dbContext);
            var answersRepo   = new EfDeletableEntityRepository <Answer>(dbContext);
            var service       = new QuestionsAndAnswersService(questionsRepo, answersRepo);
            await service.AddQuestionAsync("test", "*****@*****.**");

            Assert.Single(dbContext.Questions);
            dbContext.Questions.Add(new Question {
                Id = "testTwo", Text = "test", Email = "*****@*****.**"
            });
            await service.AddAnswerAsync("testTwo", "firstAnswer");

            Assert.Equal("test", service.GetQuestionText("testTwo"));
        }