示例#1
0
        public async stt::Task GetUserInterestRequestObjectAsync()
        {
            moq::Mock <UserInterestService.UserInterestServiceClient> mockGrpcClient = new moq::Mock <UserInterestService.UserInterestServiceClient>(moq::MockBehavior.Strict);
            GetUserInterestRequest request = new GetUserInterestRequest
            {
                ResourceNameAsUserInterestName = gagvr::UserInterestName.FromCustomerUserInterest("[CUSTOMER]", "[USER_INTEREST]"),
            };
            gagvr::UserInterest expectedResponse = new gagvr::UserInterest
            {
                ResourceNameAsUserInterestName = gagvr::UserInterestName.FromCustomerUserInterest("[CUSTOMER]", "[USER_INTEREST]"),
                TaxonomyType     = gagve::UserInterestTaxonomyTypeEnum.Types.UserInterestTaxonomyType.Unknown,
                UserInterestId   = 3507346946980618534L,
                UserInterestName = gagvr::UserInterestName.FromCustomerUserInterest("[CUSTOMER]", "[USER_INTEREST]"),
                UserInterestParentAsUserInterestName = gagvr::UserInterestName.FromCustomerUserInterest("[CUSTOMER]", "[USER_INTEREST]"),
                LaunchedToAll  = true,
                Availabilities =
                {
                    new gagvc::CriterionCategoryAvailability(),
                },
            };

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

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

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
示例#2
0
        public async Task GetUserInterestAsync2()
        {
            Mock <UserInterestService.UserInterestServiceClient> mockGrpcClient = new Mock <UserInterestService.UserInterestServiceClient>(MockBehavior.Strict);
            GetUserInterestRequest request = new GetUserInterestRequest
            {
                ResourceName = new UserInterestName("[CUSTOMER]", "[USER_INTEREST]").ToString(),
            };
            UserInterest expectedResponse = new UserInterest
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetUserInterestAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <UserInterest>(Task.FromResult(expectedResponse), null, null, null, null));
            UserInterestServiceClient client = new UserInterestServiceClientImpl(mockGrpcClient.Object, null);
            UserInterest response            = await client.GetUserInterestAsync(request);

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