Exemplo n.º 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_ID]", "[USER_INTEREST_ID]"),
            };
            gagvr::UserInterest expectedResponse = new gagvr::UserInterest
            {
                ResourceNameAsUserInterestName = gagvr::UserInterestName.FromCustomerUserInterest("[CUSTOMER_ID]", "[USER_INTEREST_ID]"),
                TaxonomyType   = gagve::UserInterestTaxonomyTypeEnum.Types.UserInterestTaxonomyType.Unknown,
                Availabilities =
                {
                    new gagvc::CriterionCategoryAvailability(),
                },
                UserInterestId   = 3507346946980618534L,
                UserInterestName = gagvr::UserInterestName.FromCustomerUserInterest("[CUSTOMER_ID]", "[USER_INTEREST_ID]"),
                UserInterestParentAsUserInterestName = gagvr::UserInterestName.FromCustomerUserInterest("[CUSTOMER_ID]", "[USER_INTEREST_ID]"),
                LaunchedToAll = true,
            };

            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();
        }
Exemplo n.º 2
0
        public void GetUserInterestRequestObject()
        {
            moq::Mock <UserInterestService.UserInterestServiceClient> mockGrpcClient = new moq::Mock <UserInterestService.UserInterestServiceClient>(moq::MockBehavior.Strict);
            GetUserInterestRequest request = new GetUserInterestRequest
            {
                ResourceNameAsUserInterestName = gagvr::UserInterestName.FromCustomerUserInterest("[CUSTOMER_ID]", "[USER_INTEREST_ID]"),
            };
            gagvr::UserInterest expectedResponse = new gagvr::UserInterest
            {
                ResourceNameAsUserInterestName = gagvr::UserInterestName.FromCustomerUserInterest("[CUSTOMER_ID]", "[USER_INTEREST_ID]"),
                TaxonomyType   = gagve::UserInterestTaxonomyTypeEnum.Types.UserInterestTaxonomyType.Unknown,
                Availabilities =
                {
                    new gagvc::CriterionCategoryAvailability(),
                },
                UserInterestId   = 3507346946980618534L,
                UserInterestName = gagvr::UserInterestName.FromCustomerUserInterest("[CUSTOMER_ID]", "[USER_INTEREST_ID]"),
                UserInterestParentAsUserInterestName = gagvr::UserInterestName.FromCustomerUserInterest("[CUSTOMER_ID]", "[USER_INTEREST_ID]"),
                LaunchedToAll = true,
            };

            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);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 3
0
        public void GetUserInterest2()
        {
            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.GetUserInterest(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            UserInterestServiceClient client = new UserInterestServiceClientImpl(mockGrpcClient.Object, null);
            UserInterest response            = client.GetUserInterest(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 4
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();
        }