public async stt::Task SignJwtResourceNamesAsync() { moq::Mock <IAMCredentials.IAMCredentialsClient> mockGrpcClient = new moq::Mock <IAMCredentials.IAMCredentialsClient>(moq::MockBehavior.Strict); SignJwtRequest request = new SignJwtRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "delegates331d18f6", }, Payload = "payloadf43c1c32", }; SignJwtResponse expectedResponse = new SignJwtResponse { KeyId = "key_id2691f630", SignedJwt = "signed_jwt09d786db", }; mockGrpcClient.Setup(x => x.SignJwtAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <SignJwtResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); IAMCredentialsClient client = new IAMCredentialsClientImpl(mockGrpcClient.Object, null); SignJwtResponse responseCallSettings = await client.SignJwtAsync(request.ServiceAccountName, request.Delegates, request.Payload, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); SignJwtResponse responseCancellationToken = await client.SignJwtAsync(request.ServiceAccountName, request.Delegates, request.Payload, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void SignJwtResourceNames() { moq::Mock <IAMCredentials.IAMCredentialsClient> mockGrpcClient = new moq::Mock <IAMCredentials.IAMCredentialsClient>(moq::MockBehavior.Strict); SignJwtRequest request = new SignJwtRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "delegates331d18f6", }, Payload = "payloadf43c1c32", }; SignJwtResponse expectedResponse = new SignJwtResponse { KeyId = "key_id2691f630", SignedJwt = "signed_jwt09d786db", }; mockGrpcClient.Setup(x => x.SignJwt(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); IAMCredentialsClient client = new IAMCredentialsClientImpl(mockGrpcClient.Object, null); SignJwtResponse response = client.SignJwt(request.ServiceAccountName, request.Delegates, request.Payload); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for SignJwt</summary> public void SignJwtRequestObject() { // Snippet: SignJwt(SignJwtRequest, CallSettings) // Create client IAMCredentialsClient iAMCredentialsClient = IAMCredentialsClient.Create(); // Initialize request argument(s) SignJwtRequest request = new SignJwtRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "", }, Payload = "", }; // Make the request SignJwtResponse response = iAMCredentialsClient.SignJwt(request); // End snippet }
/// <summary>Snippet for SignJwtAsync</summary> public async Task SignJwtRequestObjectAsync() { // Snippet: SignJwtAsync(SignJwtRequest, CallSettings) // Additional: SignJwtAsync(SignJwtRequest, CancellationToken) // Create client IAMCredentialsClient iAMCredentialsClient = await IAMCredentialsClient.CreateAsync(); // Initialize request argument(s) SignJwtRequest request = new SignJwtRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "", }, Payload = "", }; // Make the request SignJwtResponse response = await iAMCredentialsClient.SignJwtAsync(request); // End snippet }