예제 #1
0
        public void GetUserInterest()
        {
            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.GetUserInterest(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            UserInterestServiceClient client   = new UserInterestServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::UserInterest       response = client.GetUserInterest(request.ResourceName);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #2
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();
        }