public async stt::Task MutateAdsRequestObjectAsync() { moq::Mock <AdService.AdServiceClient> mockGrpcClient = new moq::Mock <AdService.AdServiceClient>(moq::MockBehavior.Strict); MutateAdsRequest request = new MutateAdsRequest { CustomerId = "customer_id3b3724cb", Operations = { new AdOperation(), }, ValidateOnly = true, PartialFailure = false, ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly, }; MutateAdsResponse expectedResponse = new MutateAdsResponse { Results = { new MutateAdResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateAdsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateAdsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AdServiceClient client = new AdServiceClientImpl(mockGrpcClient.Object, null); MutateAdsResponse responseCallSettings = await client.MutateAdsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateAdsResponse responseCancellationToken = await client.MutateAdsAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task MutateAdsAsync() { moq::Mock <AdService.AdServiceClient> mockGrpcClient = new moq::Mock <AdService.AdServiceClient>(moq::MockBehavior.Strict); MutateAdsRequest request = new MutateAdsRequest { CustomerId = "customer_id3b3724cb", Operations = { new AdOperation(), }, }; MutateAdsResponse expectedResponse = new MutateAdsResponse { Results = { new MutateAdResult(), }, }; mockGrpcClient.Setup(x => x.MutateAdsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateAdsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AdServiceClient client = new AdServiceClientImpl(mockGrpcClient.Object, null); MutateAdsResponse responseCallSettings = await client.MutateAdsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateAdsResponse responseCancellationToken = await client.MutateAdsAsync(request.CustomerId, request.Operations, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task MutateAdsAsync2() { Mock <AdService.AdServiceClient> mockGrpcClient = new Mock <AdService.AdServiceClient>(MockBehavior.Strict); MutateAdsRequest request = new MutateAdsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateAdsResponse expectedResponse = new MutateAdsResponse(); mockGrpcClient.Setup(x => x.MutateAdsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateAdsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); AdServiceClient client = new AdServiceClientImpl(mockGrpcClient.Object, null); MutateAdsResponse response = await client.MutateAdsAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }