public async stt::Task GetOfflineUserDataJobResourceNamesAsync()
        {
            moq::Mock <OfflineUserDataJobService.OfflineUserDataJobServiceClient> mockGrpcClient = new moq::Mock <OfflineUserDataJobService.OfflineUserDataJobServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetOfflineUserDataJobRequest request = new GetOfflineUserDataJobRequest
            {
                ResourceNameAsOfflineUserDataJobName = gagvr::OfflineUserDataJobName.FromCustomerOfflineUserDataJob("[CUSTOMER]", "[OFFLINE_USER_DATA_JOB]"),
            };
            gagvr::OfflineUserDataJob expectedResponse = new gagvr::OfflineUserDataJob
            {
                ResourceNameAsOfflineUserDataJobName = gagvr::OfflineUserDataJobName.FromCustomerOfflineUserDataJob("[CUSTOMER]", "[OFFLINE_USER_DATA_JOB]"),
                Id            = -6774108720365892680L,
                ExternalId    = -7826829054039660530L,
                Type          = gagve::OfflineUserDataJobTypeEnum.Types.OfflineUserDataJobType.Unspecified,
                Status        = gagve::OfflineUserDataJobStatusEnum.Types.OfflineUserDataJobStatus.Pending,
                FailureReason = gagve::OfflineUserDataJobFailureReasonEnum.Types.OfflineUserDataJobFailureReason.Unspecified,
                CustomerMatchUserListMetadata = new gagvc::CustomerMatchUserListMetadata(),
                StoreSalesMetadata            = new gagvc::StoreSalesMetadata(),
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::OfflineUserDataJob responseCancellationToken = await client.GetOfflineUserDataJobAsync(request.ResourceNameAsOfflineUserDataJobName, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public void GetOfflineUserDataJobResourceNames()
        {
            moq::Mock <OfflineUserDataJobService.OfflineUserDataJobServiceClient> mockGrpcClient = new moq::Mock <OfflineUserDataJobService.OfflineUserDataJobServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetOfflineUserDataJobRequest request = new GetOfflineUserDataJobRequest
            {
                ResourceNameAsOfflineUserDataJobName = gagvr::OfflineUserDataJobName.FromCustomerOfflineUserDataJob("[CUSTOMER]", "[OFFLINE_USER_DATA_JOB]"),
            };
            gagvr::OfflineUserDataJob expectedResponse = new gagvr::OfflineUserDataJob
            {
                ResourceNameAsOfflineUserDataJobName = gagvr::OfflineUserDataJobName.FromCustomerOfflineUserDataJob("[CUSTOMER]", "[OFFLINE_USER_DATA_JOB]"),
                Id            = -6774108720365892680L,
                ExternalId    = -7826829054039660530L,
                Type          = gagve::OfflineUserDataJobTypeEnum.Types.OfflineUserDataJobType.Unspecified,
                Status        = gagve::OfflineUserDataJobStatusEnum.Types.OfflineUserDataJobStatus.Pending,
                FailureReason = gagve::OfflineUserDataJobFailureReasonEnum.Types.OfflineUserDataJobFailureReason.Unspecified,
                CustomerMatchUserListMetadata = new gagvc::CustomerMatchUserListMetadata(),
                StoreSalesMetadata            = new gagvc::StoreSalesMetadata(),
            };

            mockGrpcClient.Setup(x => x.GetOfflineUserDataJob(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            OfflineUserDataJobServiceClient client   = new OfflineUserDataJobServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::OfflineUserDataJob       response = client.GetOfflineUserDataJob(request.ResourceNameAsOfflineUserDataJobName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }