コード例 #1
0
        public async Task TestGetVersions()
        {
            //Prepare
            TestingContext testingContext = new TestingContext();

            SetUpTestingContext(testingContext);
            ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>();
            Question             question  = dbContext.Questions.First();

            testingContext.AddPrincipalMock(question.User.UserId, Roles.User);
            testingContext.AddBusinessSecurityService();

            IQuestionService questionService = testingContext.GetService <QuestionService>();

            testingContext.DependencyMap[typeof(IQuestionService)] = questionService;
            IVersionService versionService = testingContext.GetService <VersionService>();


            int newId = await versionService.VersionQuestionAsync(question.Id);

            await versionService.AcceptQuestionAsync(newId);

            VersionInfoParametersDto versionInfoParametersDto = new VersionInfoParametersDto()
            {
                Page       = 0,
                IdQuestion = newId,
            };

            //Act
            PagedResultDto <VersionInfoDto> result = await versionService.GetVersionsAsync(versionInfoParametersDto);

            //Assert
            Assert.Equal(2, result.Count);
        }
コード例 #2
0
        public async Task <PagedResultDto <VersionInfoDto> > GetVersionsAsync(VersionInfoParametersDto versionInfoParameters)
        {
            Question questionEntity = await _dbContext.FindAsync <Question>(versionInfoParameters.IdQuestion);

            IQueryable <Question> query = _dbContext.Questions.Where(x => x.Container.Id == questionEntity.IdContainer)
                                          .OrderByDescending(x => x.Id);

            return(await PagedResultUtil.ToPagedResult(query, versionInfoParameters.Page, MaterializeQuestionList));
        }
コード例 #3
0
 public async Task <PagedResultDto <VersionInfoDto> > GetVersions([FromBody] VersionInfoParametersDto versionInfoParameters)
 {
     return(await _versionService.GetVersionsAsync(versionInfoParameters));
 }