public async stt::Task SuggestGeoTargetConstantsRequestObjectAsync() { moq::Mock <GeoTargetConstantService.GeoTargetConstantServiceClient> mockGrpcClient = new moq::Mock <GeoTargetConstantService.GeoTargetConstantServiceClient>(moq::MockBehavior.Strict); SuggestGeoTargetConstantsRequest request = new SuggestGeoTargetConstantsRequest { LocationNames = new SuggestGeoTargetConstantsRequest.Types.LocationNames(), GeoTargets = new SuggestGeoTargetConstantsRequest.Types.GeoTargets(), Locale = "locale9e6d21fb", CountryCode = "country_code8debec55", }; SuggestGeoTargetConstantsResponse expectedResponse = new SuggestGeoTargetConstantsResponse { GeoTargetConstantSuggestions = { new GeoTargetConstantSuggestion(), }, }; mockGrpcClient.Setup(x => x.SuggestGeoTargetConstantsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <SuggestGeoTargetConstantsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); GeoTargetConstantServiceClient client = new GeoTargetConstantServiceClientImpl(mockGrpcClient.Object, null); SuggestGeoTargetConstantsResponse responseCallSettings = await client.SuggestGeoTargetConstantsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); SuggestGeoTargetConstantsResponse responseCancellationToken = await client.SuggestGeoTargetConstantsAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task SuggestGeoTargetConstantsAsync2() { Mock <GeoTargetConstantService.GeoTargetConstantServiceClient> mockGrpcClient = new Mock <GeoTargetConstantService.GeoTargetConstantServiceClient>(MockBehavior.Strict); SuggestGeoTargetConstantsRequest request = new SuggestGeoTargetConstantsRequest { Locale = null, CountryCode = null, }; SuggestGeoTargetConstantsResponse expectedResponse = new SuggestGeoTargetConstantsResponse(); mockGrpcClient.Setup(x => x.SuggestGeoTargetConstantsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <SuggestGeoTargetConstantsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); GeoTargetConstantServiceClient client = new GeoTargetConstantServiceClientImpl(mockGrpcClient.Object, null); SuggestGeoTargetConstantsResponse response = await client.SuggestGeoTargetConstantsAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task SuggestGeoTargetConstantsAsync() { Mock <GeoTargetConstantService.GeoTargetConstantServiceClient> mockGrpcClient = new Mock <GeoTargetConstantService.GeoTargetConstantServiceClient>(MockBehavior.Strict); SuggestGeoTargetConstantsRequest expectedRequest = new SuggestGeoTargetConstantsRequest { Locale = new StringValue().Value, // TODO(liseno): Implicit type cast from StringValue to String failed, CountryCode = new StringValue().Value, // TODO(liseno): Implicit type cast from StringValue to String failed, }; SuggestGeoTargetConstantsResponse expectedResponse = new SuggestGeoTargetConstantsResponse(); mockGrpcClient.Setup(x => x.SuggestGeoTargetConstantsAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <SuggestGeoTargetConstantsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); GeoTargetConstantServiceClient client = new GeoTargetConstantServiceClientImpl(mockGrpcClient.Object, null); StringValue locale = new StringValue(); StringValue countryCode = new StringValue(); SuggestGeoTargetConstantsResponse response = await client.SuggestGeoTargetConstantsAsync(locale, countryCode); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }