public async stt::Task GetCustomInterestRequestObjectAsync()
        {
            moq::Mock <CustomInterestService.CustomInterestServiceClient> mockGrpcClient = new moq::Mock <CustomInterestService.CustomInterestServiceClient>(moq::MockBehavior.Strict);
            GetCustomInterestRequest request = new GetCustomInterestRequest
            {
                ResourceNameAsCustomInterestName = gagvr::CustomInterestName.FromCustomerCustomInterest("[CUSTOMER_ID]", "[CUSTOM_INTEREST_ID]"),
            };
            gagvr::CustomInterest expectedResponse = new gagvr::CustomInterest
            {
                ResourceNameAsCustomInterestName = gagvr::CustomInterestName.FromCustomerCustomInterest("[CUSTOMER_ID]", "[CUSTOM_INTEREST_ID]"),
                Status  = gagve::CustomInterestStatusEnum.Types.CustomInterestStatus.Enabled,
                Type    = gagve::CustomInterestTypeEnum.Types.CustomInterestType.CustomIntent,
                Members =
                {
                    new gagvr::CustomInterestMember(),
                },
                Id = -6774108720365892680L,
                CustomInterestName = gagvr::CustomInterestName.FromCustomerCustomInterest("[CUSTOMER_ID]", "[CUSTOM_INTEREST_ID]"),
                Description        = "description2cf9da67",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            gagvr::CustomInterest responseCancellationToken = await client.GetCustomInterestAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        public async Task GetCustomInterestAsync2()
        {
            Mock <CustomInterestService.CustomInterestServiceClient> mockGrpcClient = new Mock <CustomInterestService.CustomInterestServiceClient>(MockBehavior.Strict);
            GetCustomInterestRequest request = new GetCustomInterestRequest
            {
                ResourceName = new CustomInterestName("[CUSTOMER]", "[CUSTOM_INTEREST]").ToString(),
            };
            CustomInterest expectedResponse = new CustomInterest
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetCustomInterestAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <CustomInterest>(Task.FromResult(expectedResponse), null, null, null, null));
            CustomInterestServiceClient client = new CustomInterestServiceClientImpl(mockGrpcClient.Object, null);
            CustomInterest response            = await client.GetCustomInterestAsync(request);

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