Ejemplo n.º 1
0
        public void GetDetailedDemographic()
        {
            moq::Mock <DetailedDemographicService.DetailedDemographicServiceClient> mockGrpcClient = new moq::Mock <DetailedDemographicService.DetailedDemographicServiceClient>(moq::MockBehavior.Strict);
            GetDetailedDemographicRequest request = new GetDetailedDemographicRequest
            {
                ResourceNameAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"),
            };
            gagvr::DetailedDemographic expectedResponse = new gagvr::DetailedDemographic
            {
                ResourceNameAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"),
                Id = -6774108720365892680L,
                DetailedDemographicName         = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"),
                ParentAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"),
                LaunchedToAll  = true,
                Availabilities =
                {
                    new gagvc::CriterionCategoryAvailability(),
                },
            };

            mockGrpcClient.Setup(x => x.GetDetailedDemographic(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            DetailedDemographicServiceClient client   = new DetailedDemographicServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::DetailedDemographic       response = client.GetDetailedDemographic(request.ResourceName);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        public async stt::Task GetDetailedDemographicRequestObjectAsync()
        {
            moq::Mock <DetailedDemographicService.DetailedDemographicServiceClient> mockGrpcClient = new moq::Mock <DetailedDemographicService.DetailedDemographicServiceClient>(moq::MockBehavior.Strict);
            GetDetailedDemographicRequest request = new GetDetailedDemographicRequest
            {
                ResourceNameAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"),
            };
            gagvr::DetailedDemographic expectedResponse = new gagvr::DetailedDemographic
            {
                ResourceNameAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"),
                Id = -6774108720365892680L,
                DetailedDemographicName         = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"),
                ParentAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"),
                LaunchedToAll  = true,
                Availabilities =
                {
                    new gagvc::CriterionCategoryAvailability(),
                },
            };

            mockGrpcClient.Setup(x => x.GetDetailedDemographicAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::DetailedDemographic>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            DetailedDemographicServiceClient client = new DetailedDemographicServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::DetailedDemographic       responseCallSettings = await client.GetDetailedDemographicAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::DetailedDemographic responseCancellationToken = await client.GetDetailedDemographicAsync(request, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }