public async stt::Task GetWebhookRequestObjectAsync() { moq::Mock <Webhooks.WebhooksClient> mockGrpcClient = new moq::Mock <Webhooks.WebhooksClient>(moq::MockBehavior.Strict); GetWebhookRequest request = new GetWebhookRequest { WebhookName = WebhookName.FromProjectLocationAgentWebhook("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]"), }; Webhook expectedResponse = new Webhook { WebhookName = WebhookName.FromProjectLocationAgentWebhook("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]"), DisplayName = "display_name137f65c2", GenericWebService = new Webhook.Types.GenericWebService(), Disabled = false, Timeout = new wkt::Duration(), }; mockGrpcClient.Setup(x => x.GetWebhookAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Webhook>(stt::Task.FromResult(expectedResponse), null, null, null, null)); WebhooksClient client = new WebhooksClientImpl(mockGrpcClient.Object, null); Webhook responseCallSettings = await client.GetWebhookAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Webhook responseCancellationToken = await client.GetWebhookAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void UpdateWebhook() { moq::Mock <Webhooks.WebhooksClient> mockGrpcClient = new moq::Mock <Webhooks.WebhooksClient>(moq::MockBehavior.Strict); UpdateWebhookRequest request = new UpdateWebhookRequest { Webhook = new Webhook(), UpdateMask = new wkt::FieldMask(), }; Webhook expectedResponse = new Webhook { WebhookName = WebhookName.FromProjectLocationAgentWebhook("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]"), DisplayName = "display_name137f65c2", GenericWebService = new Webhook.Types.GenericWebService(), Disabled = false, Timeout = new wkt::Duration(), ServiceDirectory = new Webhook.Types.ServiceDirectoryConfig(), }; mockGrpcClient.Setup(x => x.UpdateWebhook(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); WebhooksClient client = new WebhooksClientImpl(mockGrpcClient.Object, null); Webhook response = client.UpdateWebhook(request.Webhook, request.UpdateMask); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void DeleteWebhookResourceNames() { moq::Mock <Webhooks.WebhooksClient> mockGrpcClient = new moq::Mock <Webhooks.WebhooksClient>(moq::MockBehavior.Strict); DeleteWebhookRequest request = new DeleteWebhookRequest { WebhookName = WebhookName.FromProjectLocationAgentWebhook("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteWebhook(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); WebhooksClient client = new WebhooksClientImpl(mockGrpcClient.Object, null); client.DeleteWebhook(request.WebhookName); mockGrpcClient.VerifyAll(); }
public async stt::Task DeleteWebhookResourceNamesAsync() { moq::Mock <Webhooks.WebhooksClient> mockGrpcClient = new moq::Mock <Webhooks.WebhooksClient>(moq::MockBehavior.Strict); DeleteWebhookRequest request = new DeleteWebhookRequest { WebhookName = WebhookName.FromProjectLocationAgentWebhook("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteWebhookAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); WebhooksClient client = new WebhooksClientImpl(mockGrpcClient.Object, null); await client.DeleteWebhookAsync(request.WebhookName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeleteWebhookAsync(request.WebhookName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }