Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        public bool HasVideoPlayerPermission()
        {
            GetLicenseRequest request = new GetLicenseRequest
            {
                ClientId = _connectionService.ClientId
            };

            GetLicenseResponse response = _connectionService.Execute <GetLicenseResponse>(request);

            return(response.LicensePermissions.UgcsVideoPlayer);
        }
Ejemplo n.º 5
0
 /// <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
 }
Ejemplo n.º 6
0
        /// <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
        }
Ejemplo n.º 7
0
 public Task <GetLicenseResponse> GetAsync(GetLicenseRequest request, CancellationToken cancellationToken = default)
 {
     request.BeforeRequest();
     return(DoRequestAsync <GetLicenseRequest, GetLicenseResponse>(request, cancellationToken));
 }
Ejemplo n.º 8
0
 public GetLicenseResponse Get(GetLicenseRequest request)
 {
     request.BeforeRequest();
     return(DoRequest <GetLicenseRequest, GetLicenseResponse>(request));
 }