public void GetCustomAudience() { moq::Mock <CustomAudienceService.CustomAudienceServiceClient> mockGrpcClient = new moq::Mock <CustomAudienceService.CustomAudienceServiceClient>(moq::MockBehavior.Strict); GetCustomAudienceRequest request = new GetCustomAudienceRequest { ResourceNameAsCustomAudienceName = gagvr::CustomAudienceName.FromCustomerCustomAudience("[CUSTOMER_ID]", "[CUSTOM_AUDIENCE_ID]"), }; gagvr::CustomAudience expectedResponse = new gagvr::CustomAudience { ResourceNameAsCustomAudienceName = gagvr::CustomAudienceName.FromCustomerCustomAudience("[CUSTOMER_ID]", "[CUSTOM_AUDIENCE_ID]"), Id = -6774108720365892680L, Status = gagve::CustomAudienceStatusEnum.Types.CustomAudienceStatus.Enabled, CustomAudienceName = gagvr::CustomAudienceName.FromCustomerCustomAudience("[CUSTOMER_ID]", "[CUSTOM_AUDIENCE_ID]"), Type = gagve::CustomAudienceTypeEnum.Types.CustomAudienceType.Interest, Description = "description2cf9da67", Members = { new gagvr::CustomAudienceMember(), }, }; mockGrpcClient.Setup(x => x.GetCustomAudience(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CustomAudienceServiceClient client = new CustomAudienceServiceClientImpl(mockGrpcClient.Object, null); gagvr::CustomAudience response = client.GetCustomAudience(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task MutateCustomAudiencesAsync() { moq::Mock <CustomAudienceService.CustomAudienceServiceClient> mockGrpcClient = new moq::Mock <CustomAudienceService.CustomAudienceServiceClient>(moq::MockBehavior.Strict); MutateCustomAudiencesRequest request = new MutateCustomAudiencesRequest { CustomerId = "customer_id3b3724cb", Operations = { new CustomAudienceOperation(), }, }; MutateCustomAudiencesResponse expectedResponse = new MutateCustomAudiencesResponse { Results = { new MutateCustomAudienceResult(), }, }; mockGrpcClient.Setup(x => x.MutateCustomAudiencesAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateCustomAudiencesResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CustomAudienceServiceClient client = new CustomAudienceServiceClientImpl(mockGrpcClient.Object, null); MutateCustomAudiencesResponse responseCallSettings = await client.MutateCustomAudiencesAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateCustomAudiencesResponse responseCancellationToken = await client.MutateCustomAudiencesAsync(request.CustomerId, request.Operations, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task GetCustomAudienceRequestObjectAsync() { moq::Mock <CustomAudienceService.CustomAudienceServiceClient> mockGrpcClient = new moq::Mock <CustomAudienceService.CustomAudienceServiceClient>(moq::MockBehavior.Strict); GetCustomAudienceRequest request = new GetCustomAudienceRequest { ResourceNameAsCustomAudienceName = gagvr::CustomAudienceName.FromCustomerCustomAudience("[CUSTOMER_ID]", "[CUSTOM_AUDIENCE_ID]"), }; gagvr::CustomAudience expectedResponse = new gagvr::CustomAudience { ResourceNameAsCustomAudienceName = gagvr::CustomAudienceName.FromCustomerCustomAudience("[CUSTOMER_ID]", "[CUSTOM_AUDIENCE_ID]"), Id = -6774108720365892680L, Status = gagve::CustomAudienceStatusEnum.Types.CustomAudienceStatus.Enabled, CustomAudienceName = gagvr::CustomAudienceName.FromCustomerCustomAudience("[CUSTOMER_ID]", "[CUSTOM_AUDIENCE_ID]"), Type = gagve::CustomAudienceTypeEnum.Types.CustomAudienceType.Interest, Description = "description2cf9da67", Members = { new gagvr::CustomAudienceMember(), }, }; mockGrpcClient.Setup(x => x.GetCustomAudienceAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::CustomAudience>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CustomAudienceServiceClient client = new CustomAudienceServiceClientImpl(mockGrpcClient.Object, null); gagvr::CustomAudience responseCallSettings = await client.GetCustomAudienceAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::CustomAudience responseCancellationToken = await client.GetCustomAudienceAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void MutateCustomAudiences() { moq::Mock <CustomAudienceService.CustomAudienceServiceClient> mockGrpcClient = new moq::Mock <CustomAudienceService.CustomAudienceServiceClient>(moq::MockBehavior.Strict); MutateCustomAudiencesRequest request = new MutateCustomAudiencesRequest { CustomerId = "customer_id3b3724cb", Operations = { new CustomAudienceOperation(), }, }; MutateCustomAudiencesResponse expectedResponse = new MutateCustomAudiencesResponse { Results = { new MutateCustomAudienceResult(), }, }; mockGrpcClient.Setup(x => x.MutateCustomAudiences(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CustomAudienceServiceClient client = new CustomAudienceServiceClientImpl(mockGrpcClient.Object, null); MutateCustomAudiencesResponse response = client.MutateCustomAudiences(request.CustomerId, request.Operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }