public void GetGeographicView() { moq::Mock <GeographicViewService.GeographicViewServiceClient> mockGrpcClient = new moq::Mock <GeographicViewService.GeographicViewServiceClient>(moq::MockBehavior.Strict); GetGeographicViewRequest request = new GetGeographicViewRequest { ResourceNameAsGeographicViewName = gagvr::GeographicViewName.FromCustomerCountryCriterionLocationType("[CUSTOMER_ID]", "[COUNTRY_CRITERION_ID]", "[LOCATION_TYPE]"), }; gagvr::GeographicView expectedResponse = new gagvr::GeographicView { ResourceNameAsGeographicViewName = gagvr::GeographicViewName.FromCustomerCountryCriterionLocationType("[CUSTOMER_ID]", "[COUNTRY_CRITERION_ID]", "[LOCATION_TYPE]"), LocationType = gagve::GeoTargetingTypeEnum.Types.GeoTargetingType.LocationOfPresence, CountryCriterionId = 7801114990940938649L, }; mockGrpcClient.Setup(x => x.GetGeographicView(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); GeographicViewServiceClient client = new GeographicViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::GeographicView response = client.GetGeographicView(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetGeographicViewRequestObject() { moq::Mock <GeographicViewService.GeographicViewServiceClient> mockGrpcClient = new moq::Mock <GeographicViewService.GeographicViewServiceClient>(moq::MockBehavior.Strict); GetGeographicViewRequest request = new GetGeographicViewRequest { ResourceNameAsGeographicViewName = gagvr::GeographicViewName.FromCustomerGeographicView("[CUSTOMER]", "[GEOGRAPHIC_VIEW]"), }; gagvr::GeographicView expectedResponse = new gagvr::GeographicView { ResourceNameAsGeographicViewName = gagvr::GeographicViewName.FromCustomerGeographicView("[CUSTOMER]", "[GEOGRAPHIC_VIEW]"), LocationType = gagve::GeoTargetingTypeEnum.Types.GeoTargetingType.LocationOfPresence, CountryCriterionId = 7801114990940938649L, }; mockGrpcClient.Setup(x => x.GetGeographicView(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); GeographicViewServiceClient client = new GeographicViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::GeographicView response = client.GetGeographicView(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetGeographicViewRequestObjectAsync() { moq::Mock <GeographicViewService.GeographicViewServiceClient> mockGrpcClient = new moq::Mock <GeographicViewService.GeographicViewServiceClient>(moq::MockBehavior.Strict); GetGeographicViewRequest request = new GetGeographicViewRequest { ResourceNameAsGeographicViewName = gagvr::GeographicViewName.FromCustomerCountryCriterionLocationType("[CUSTOMER_ID]", "[COUNTRY_CRITERION_ID]", "[LOCATION_TYPE]"), }; gagvr::GeographicView expectedResponse = new gagvr::GeographicView { ResourceNameAsGeographicViewName = gagvr::GeographicViewName.FromCustomerCountryCriterionLocationType("[CUSTOMER_ID]", "[COUNTRY_CRITERION_ID]", "[LOCATION_TYPE]"), LocationType = gagve::GeoTargetingTypeEnum.Types.GeoTargetingType.LocationOfPresence, CountryCriterionId = 7801114990940938649L, }; mockGrpcClient.Setup(x => x.GetGeographicViewAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::GeographicView>(stt::Task.FromResult(expectedResponse), null, null, null, null)); GeographicViewServiceClient client = new GeographicViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::GeographicView responseCallSettings = await client.GetGeographicViewAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::GeographicView responseCancellationToken = await client.GetGeographicViewAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }