public async stt::Task UpdateVersionAsync() { moq::Mock <Versions.VersionsClient> mockGrpcClient = new moq::Mock <Versions.VersionsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); UpdateVersionRequest request = new UpdateVersionRequest { Version = new Version(), UpdateMask = new wkt::FieldMask(), }; Version expectedResponse = new Version { VersionName = VersionName.FromProjectLocationAgentFlowVersion("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[VERSION]"), DisplayName = "display_name137f65c2", Description = "description2cf9da67", NluSettings = new NluSettings(), CreateTime = new wkt::Timestamp(), State = Version.Types.State.Succeeded, }; mockGrpcClient.Setup(x => x.UpdateVersionAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Version>(stt::Task.FromResult(expectedResponse), null, null, null, null)); VersionsClient client = new VersionsClientImpl(mockGrpcClient.Object, null); Version responseCallSettings = await client.UpdateVersionAsync(request.Version, request.UpdateMask, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Version responseCancellationToken = await client.UpdateVersionAsync(request.Version, request.UpdateMask, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for UpdateVersionAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task UpdateVersionRequestObjectAsync() { // Create client VersionsClient versionsClient = await VersionsClient.CreateAsync(); // Initialize request argument(s) UpdateVersionRequest request = new UpdateVersionRequest { Name = "", Version = new Version(), UpdateMask = new FieldMask(), }; // Make the request Operation <Version, OperationMetadataV1> response = await versionsClient.UpdateVersionAsync(request); // Poll until the returned long-running operation is complete Operation <Version, OperationMetadataV1> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result Version result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <Version, OperationMetadataV1> retrievedResponse = await versionsClient.PollOnceUpdateVersionAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Version retrievedResult = retrievedResponse.Result; } }
public async stt::Task UpdateVersionAsync() { moq::Mock <Versions.VersionsClient> mockGrpcClient = new moq::Mock <Versions.VersionsClient>(moq::MockBehavior.Strict); UpdateVersionRequest request = new UpdateVersionRequest { Version = new Version(), UpdateMask = new wkt::FieldMask(), }; Version expectedResponse = new Version { VersionName = VersionName.FromProjectVersion("[PROJECT]", "[VERSION]"), Description = "description2cf9da67", VersionNumber = -1567505473, CreateTime = new wkt::Timestamp(), Status = Version.Types.VersionStatus.Ready, }; mockGrpcClient.Setup(x => x.UpdateVersionAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Version>(stt::Task.FromResult(expectedResponse), null, null, null, null)); VersionsClient client = new VersionsClientImpl(mockGrpcClient.Object, null); Version responseCallSettings = await client.UpdateVersionAsync(request.Version, request.UpdateMask, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Version responseCancellationToken = await client.UpdateVersionAsync(request.Version, request.UpdateMask, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for UpdateVersion</summary> public void UpdateVersionRequestObject() { // Snippet: UpdateVersion(UpdateVersionRequest, CallSettings) // Create client VersionsClient versionsClient = VersionsClient.Create(); // Initialize request argument(s) UpdateVersionRequest request = new UpdateVersionRequest { Name = "", Version = new gcav::Version(), UpdateMask = new FieldMask(), }; // Make the request Operation <gcav::Version, OperationMetadataV1> response = versionsClient.UpdateVersion(request); // Poll until the returned long-running operation is complete Operation <gcav::Version, OperationMetadataV1> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result gcav::Version result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <gcav::Version, OperationMetadataV1> retrievedResponse = versionsClient.PollOnceUpdateVersion(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result gcav::Version retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for UpdateVersion</summary> public void UpdateVersionRequestObject() { // Snippet: UpdateVersion(UpdateVersionRequest, CallSettings) // Create client VersionsClient versionsClient = VersionsClient.Create(); // Initialize request argument(s) UpdateVersionRequest request = new UpdateVersionRequest { Version = new gcdcv::Version(), UpdateMask = new FieldMask(), }; // Make the request gcdcv::Version response = versionsClient.UpdateVersion(request); // End snippet }
/// <summary>Snippet for UpdateVersionAsync</summary> public async Task UpdateVersionRequestObjectAsync() { // Snippet: UpdateVersionAsync(UpdateVersionRequest, CallSettings) // Additional: UpdateVersionAsync(UpdateVersionRequest, CancellationToken) // Create client VersionsClient versionsClient = await VersionsClient.CreateAsync(); // Initialize request argument(s) UpdateVersionRequest request = new UpdateVersionRequest { Version = new gcdcv::Version(), UpdateMask = new FieldMask(), }; // Make the request gcdcv::Version response = await versionsClient.UpdateVersionAsync(request); // End snippet }
public void UpdateVersion() { moq::Mock <Versions.VersionsClient> mockGrpcClient = new moq::Mock <Versions.VersionsClient>(moq::MockBehavior.Strict); UpdateVersionRequest request = new UpdateVersionRequest { Version = new Version(), UpdateMask = new wkt::FieldMask(), }; Version expectedResponse = new Version { VersionName = VersionName.FromProjectVersion("[PROJECT]", "[VERSION]"), Description = "description2cf9da67", VersionNumber = -1567505473, CreateTime = new wkt::Timestamp(), Status = Version.Types.VersionStatus.Ready, }; mockGrpcClient.Setup(x => x.UpdateVersion(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); VersionsClient client = new VersionsClientImpl(mockGrpcClient.Object, null); Version response = client.UpdateVersion(request.Version, request.UpdateMask); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
static async Task FullHandlerAsync(string token, string[] val, bool dev) { if (!val.Any()) { val = all_val; } var hasWindows = val.Any(x => x.StartsWith("win-")); var hasLinux = val.Any(x => x.StartsWith("linux-")); Dictionary <DeploymentMode, string[]> publishDict = new() { { DeploymentMode.SCD, val }, }; if (hasWindows) { var fde_val = val.Where(x => x.StartsWith("win-")).ToArray(); // 仅 Windows 发行依赖部署(FDE) 包 if (fde_val.Any()) { publishDict.Add(DeploymentMode.FDE, fde_val); } // X. (本地)将发布 Host 入口点重定向到 Bin 目录中 var hpTasks = publishDict.Keys.Select(x => Task.Run(() => StepAppHostPatcher.Handler(dev, x, endWriteOK: false))).ToArray(); await Task.WhenAll(hpTasks); } List <PublishDirInfo> publishDirs = new(); // 5. (本地)验证发布文件夹与计算文件哈希 foreach (var item in publishDict) { var dirNames = ScanDirectory(item.Key, item.Value, dev); if (dirNames.Any_Nullable()) { publishDirs.AddRange(dirNames !); } } // 8. (本地)读取上一步操作后的 Publish.json 生成压缩包并计算哈希值写入 Publish.json var parallelTasks = new List <Task>(); Console.WriteLine("7z Step 正在创建压缩包..."); // 创建压缩包 var gs = publishDirs.Select(x => Task.Run(() => GenerateCompressedPackage(dev, x))); parallelTasks.AddRange(gs); await Task.WhenAll(parallelTasks); parallelTasks.Clear(); if (hasWindows) { var win_publishDirs = publishDirs.Where(x => x.Name.StartsWith("win-")); Console.WriteLine("nsis Step 正在打包 EXE installer..."); NSISBuild(dev, win_publishDirs); } if (hasLinux) { var linux_publishDirs = publishDirs.Where(x => x.Name.StartsWith("linux-")); Console.WriteLine("rpm Step 正在打包 CentOS/RedHat Linux installer..."); // Create a CentOS/RedHat Linux installer Step_rpm.Init(); var rpms = linux_publishDirs.Select(x => Task.Run(() => Step_rpm.HandlerItem(dev, x))); parallelTasks.AddRange(rpms); await Task.WhenAll(parallelTasks); parallelTasks.Clear(); Console.WriteLine("deb Step 正在打包 Ubuntu/Debian Linux installer..."); // Create a Ubuntu/Debian Linux installer var debs = linux_publishDirs.Select(x => Task.Run(() => Step_deb.HandlerItem(dev, x))); parallelTasks.AddRange(debs); await Task.WhenAll(parallelTasks); parallelTasks.Clear(); } #region rel 12. (本地)读取 **Publish.json** 中的 SHA256 值写入 release-template.md //Console.WriteLine("rel Step 正在写入 SHA256..."); //// 12. (本地)读取 **Publish.json** 中的 SHA256 值写入 release-template.md //StepRel.Handler2(endWriteOK: false); #endregion var winX64 = publishDirs.Where(x => x.Name.StartsWith("win-x64")).ToArray(); if (winX64.Any()) { Console.WriteLine("wdb Step 正在上传新版本数据中..."); // wdb 11. (云端)读取上一步上传的数据写入数据库中 var request = new UpdateVersionRequest { Version = GetVersion(dev), DirNames = winX64, }; using var client = GetHttpClient(token, dev); using var req = GetRequestContent(request); using var rsp = await client.PutAsync(api_version_create, req); if (rsp.StatusCode == HttpStatusCode.InternalServerError) { var html = await rsp.Content.ReadAsStringAsync(); throw new HttpRequestException(html); } rsp.EnsureSuccessStatusCode(); var apiResponse = await GetResponseAsync(rsp); apiResponse = apiResponse.ThrowIsNull(nameof(apiResponse)); if (!apiResponse.IsSuccess) { throw new Exception(apiResponse.Message); } } Console.WriteLine("OK"); }