public async stt::Task GetAsync() { moq::Mock <Licenses.LicensesClient> mockGrpcClient = new moq::Mock <Licenses.LicensesClient>(moq::MockBehavior.Strict); GetLicenseRequest request = new GetLicenseRequest { License = "license75798771", Project = "projectaa6ff846", }; License expectedResponse = new License { Id = "id74b70bb8", LicenseCode = "license_code196a50c0", Kind = "kindf7aa39d9", Name = "name1c9368b0", Transferable = false, CreationTimestamp = "creation_timestamp235e59a1", ResourceRequirements = new LicenseResourceRequirements(), ChargesUseFee = true, Description = "description2cf9da67", SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <License>(stt::Task.FromResult(expectedResponse), null, null, null, null)); LicensesClient client = new LicensesClientImpl(mockGrpcClient.Object, null); License responseCallSettings = await client.GetAsync(request.Project, request.License, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); License responseCancellationToken = await client.GetAsync(request.Project, request.License, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void Get() { moq::Mock <Licenses.LicensesClient> mockGrpcClient = new moq::Mock <Licenses.LicensesClient>(moq::MockBehavior.Strict); GetLicenseRequest request = new GetLicenseRequest { License = "license75798771", Project = "projectaa6ff846", }; License expectedResponse = new License { Id = "id74b70bb8", LicenseCode = "license_code196a50c0", Kind = "kindf7aa39d9", Name = "name1c9368b0", Transferable = false, CreationTimestamp = "creation_timestamp235e59a1", ResourceRequirements = new LicenseResourceRequirements(), ChargesUseFee = true, Description = "description2cf9da67", SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); LicensesClient client = new LicensesClientImpl(mockGrpcClient.Object, null); License response = client.Get(request.Project, request.License); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task <LicenseVm> GetLicenseAsync(long?nodeId = null) { try { if (!await TryConnectAsync().ConfigureAwait(false)) { throw new LicensorException("Unable to establish connection with licensor."); } GetLicenseRequest request = new GetLicenseRequest(nodeId); await SendRequestAsync(request).ConfigureAwait(false); var response = await GetResponseAsync(request).ConfigureAwait(false); if (response is LicensesResponse licensesResponse) { var license = licensesResponse.Licenses.FirstOrDefault(); return(license); } else if (response is ResultResponse resultResponse) { throw new ResponseException($"Failed to edit node. Response error message: {resultResponse.ErrorMessage}"); } throw new ResponseException($"Unknown response type: {response.ResponseType}"); } catch (Exception ex) { Logger.WriteLog(ex); return(null); } }
public bool HasVideoPlayerPermission() { GetLicenseRequest request = new GetLicenseRequest { ClientId = _connectionService.ClientId }; GetLicenseResponse response = _connectionService.Execute <GetLicenseResponse>(request); return(response.LicensePermissions.UgcsVideoPlayer); }
/// <summary>Snippet for Get</summary> public void GetRequestObject() { // Snippet: Get(GetLicenseRequest, CallSettings) // Create client LicensesClient licensesClient = LicensesClient.Create(); // Initialize request argument(s) GetLicenseRequest request = new GetLicenseRequest { License = "", Project = "", }; // Make the request License response = licensesClient.Get(request); // End snippet }
/// <summary>Snippet for GetAsync</summary> public async Task GetRequestObjectAsync() { // Snippet: GetAsync(GetLicenseRequest, CallSettings) // Additional: GetAsync(GetLicenseRequest, CancellationToken) // Create client LicensesClient licensesClient = await LicensesClient.CreateAsync(); // Initialize request argument(s) GetLicenseRequest request = new GetLicenseRequest { License = "", Project = "", }; // Make the request License response = await licensesClient.GetAsync(request); // End snippet }
public Task <GetLicenseResponse> GetAsync(GetLicenseRequest request, CancellationToken cancellationToken = default) { request.BeforeRequest(); return(DoRequestAsync <GetLicenseRequest, GetLicenseResponse>(request, cancellationToken)); }
public GetLicenseResponse Get(GetLicenseRequest request) { request.BeforeRequest(); return(DoRequest <GetLicenseRequest, GetLicenseResponse>(request)); }