コード例 #1
0
        public async Task GetIssuesByExampleType()
        {
            //Arrange
            var searchSpecification = new SearchSpecificationDto();
            var type       = typeof(SearchIssuesWithoutClosed);
            var issueCount = new IssueCount {
                FilteredIssue = 2
            };
            var filteredIssueList = new FilteredIssueListDto {
                Count = issueCount, Issues = GetIssueList()
            };

            var service = new IssueService(unitOfWork.Object, searchIssuesBox.Object, issueRepository.Object);

            searchIssuesBox.Setup(x => x.ConcreteSearch(It.IsAny <Type>(), searchSpecification)).Verifiable();

            searchIssuesBox.Setup(x => x.Search(x => x.Id != 0, searchSpecification)).Returns(Task.FromResult(filteredIssueList));

            unitOfWork.Setup(x => x.Mapper().Map <List <GetIssueListDto> >(filteredIssueList.Issues)).Returns(GetIssueListDto());

            //Act
            var action = await service.GetIssues(searchSpecification);

            //Assert
            Assert.NotNull(action.Data);
            searchIssuesBox.Verify(x => x.ConcreteSearch(It.IsAny <Type>(), searchSpecification), Times.Once);
        }
コード例 #2
0
ファイル: SearchBy.cs プロジェクト: wystrzal/TicketManagement
        public virtual async Task <FilteredIssueListDto> SearchIssues(Expression <Func <Issue, bool> > searchFor,
                                                                      Expression <Func <Issue, bool> > specification, SearchSpecificationDto searchSpecification)
        {
            FilteredIssueListDto filteredIssueList = new FilteredIssueListDto();
            IssueCount           issueCount        = new IssueCount();

            var specificationValue = specification.Compile();
            var searchForValue     = searchFor.Compile();

            filteredIssueList.Issues = await issueRepository.GetIssues(x => specificationValue(x) && searchForValue(x),
                                                                       searchSpecification.PageIndex, searchSpecification.PageSize);

            issueCount.FilteredIssue = await issueRepository.CountIssues(x => specificationValue(x) && searchForValue(x));

            await CountSpecificStatusIssues(issueCount, searchForValue);

            filteredIssueList.Count = issueCount;

            return(filteredIssueList);
        }
コード例 #3
0
        public async Task SearchTestAsync()
        {
            //Arrange
            var searchSpecification = new SearchSpecificationDto();
            var service             = new SearchSpecificationBox(searchBy.Object);

            var issueCount = new IssueCount()
            {
                FilteredIssue = 2
            };
            var filteredIssueList = new FilteredIssueListDto()
            {
                Count = issueCount
            };

            searchBy.Setup(x => x.SearchIssues(x => x.Id != 0, It.IsAny <Expression <Func <Issue, bool> > >(), searchSpecification))
            .Returns(Task.FromResult(filteredIssueList));

            //Act
            var action = await service.Search(x => x.Id != 0, searchSpecification);

            //Assert
            Assert.Equal(2, action.Count.FilteredIssue);
        }