public void Should_Add_Question_With_Authorized_User() { AbpSession.UserId = UsingDbContext(context => context.Users.Single(u => u.UserName == "admin" && u.TenantId == AbpSession.TenantId.Value).Id); const string questionTitle = "Test question title 1"; //Question does not exists now UsingDbContext(context => context.Questions.FirstOrDefault(q => q.Title == questionTitle).ShouldBe(null)); //Create the question _questionAppService.CreateQuestion( new CreateQuestionInput { Title = questionTitle, Body = "A dummy question text..." }); //Question is added now var question = UsingDbContext(context => context.Questions.FirstOrDefault(q => q.Title == questionTitle)); question.ShouldNotBe(null); //Vote up the question var voteUpOutput = _questionAppService.QuestionVoteUp(new EntityDto(question.Id)); voteUpOutput.VoteCount.ShouldBe(1); //Vote down the question var voteDownOutput = _questionAppService.QuestionVoteDown(new EntityDto(question.Id)); voteDownOutput.VoteCount.ShouldBe(0); }