示例#1
0
        public async Task <ListTestsResponse> ListTests(ListTestsRequest request)
        {
            var lstRequest = new ListTestsDataRequest(request.FilteringOrders, request.Range, false, request.ReturnNotSaved);
            var tests      = await TestsStorage.ListTestsDataAsync(lstRequest);

            var testsIds  = tests.Tests.Select(c => c.TestId).ToArray();
            var getInfosR = new RunnerService.API.Models.GetTestsInfoRequest(testsIds);

            RunnerService.API.Models.GetTestsInfoResponse getInfosResp = request.ReturnNotSaved
                ? (RunnerService.API.Models.GetTestsInfoResponse)null
                : (RunnerService.API.Models.GetTestsInfoResponse) await RunnerService.GetTestsInfoAsync(getInfosR);

            var fullInfos = tests.Tests.Select(c => (Case: c, RunInfo: getInfosResp == null ? (RunnerService.API.Models.TestRunInfo)null : getInfosResp.RunInfos.FirstOrDefault(r => r.TestId == c.TestId)));
            //var fullInfos = tests.Tests.Zip(getInfosResp?.RunInfos ?? ((RunnerService.API.Models.TestRunInfo)null).Repeat(tests.Tests.Length).ToArray() , (Case, RunInfo) => (Case, RunInfo));

            var response = new ListTestsResponse(ddd().ToArray(), tests.TotalCount);

            return(response);

            IEnumerable <TestInfo> ddd()
            {
                foreach (var info in fullInfos)
                {
                    yield return(new TestInfo()
                    {
                        TestId = info.Case.TestId,
                        TestName = info.Case.TestName,
                        Author = info.Case.AuthorName == null
                            ? null
                            : new GetUserInfoResponse(info.Case.AuthorName, null, null),
                        Target = new TestCaseInfo()
                        {
                            DisplayName = info.Case.TestDescription,
                            TargetType = info.Case?.Data?.Type,
                            Parameters = info.Case?.Data?.Parameters,
                            CreateDate = info.Case?.CreationDate ?? default,
                            KeyParameters = info.Case?.Data?.KeyParameters.Select(p => p.Key + "###" + p.Value).Aggregate(Environment.NewLine) // Someone, pls, rewrite :D
                        },
 partial void Modify_ListTestsRequest(ref ListTestsRequest request, ref gaxgrpc::CallSettings settings);
 /// <summary>
 /// List the tests of a sessesion.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A pageable asynchronous sequence of <see cref="Test"/> resources.</returns>
 public override gax::PagedAsyncEnumerable <ListTestsResponse, Test> ListTestsAsync(ListTestsRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_ListTestsRequest(ref request, ref callSettings);
     return(new gaxgrpc::GrpcPagedAsyncEnumerable <ListTestsRequest, ListTestsResponse, Test>(_callListTests, request, callSettings));
 }
 /// <summary>
 /// List the tests of a sessesion.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A pageable asynchronous sequence of <see cref="Test"/> resources.</returns>
 public virtual gax::PagedAsyncEnumerable <ListTestsResponse, Test> ListTestsAsync(ListTestsRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();