Ejemplo n.º 1
0
        public async stt::Task BatchGetAssetsHistoryRequestObjectAsync()
        {
            moq::Mock <AssetService.AssetServiceClient> mockGrpcClient = new moq::Mock <AssetService.AssetServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest
            {
                ParentAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
                AssetNames           =
                {
                    "asset_namese42cd316",
                },
                ContentType    = ContentType.IamPolicy,
                ReadTimeWindow = new TimeWindow(),
            };
            BatchGetAssetsHistoryResponse expectedResponse = new BatchGetAssetsHistoryResponse
            {
                Assets =
                {
                    new TemporalAsset(),
                },
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            BatchGetAssetsHistoryResponse responseCancellationToken = await client.BatchGetAssetsHistoryAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        public async Task BatchGetAssetsHistoryAsync()
        {
            Mock <AssetService.AssetServiceClient> mockGrpcClient = new Mock <AssetService.AssetServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            BatchGetAssetsHistoryRequest expectedRequest = new BatchGetAssetsHistoryRequest
            {
                Parent = new Google.Api.Gax.ResourceNames.ProjectName("[PROJECT]").ToString(),
            };
            BatchGetAssetsHistoryResponse expectedResponse = new BatchGetAssetsHistoryResponse();

            mockGrpcClient.Setup(x => x.BatchGetAssetsHistoryAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <BatchGetAssetsHistoryResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            AssetServiceClient            client          = new AssetServiceClientImpl(mockGrpcClient.Object, null);
            string                        formattedParent = new Google.Api.Gax.ResourceNames.ProjectName("[PROJECT]").ToString();
            BatchGetAssetsHistoryResponse response        = await client.BatchGetAssetsHistoryAsync(formattedParent);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 3
0
        public async Task BatchGetAssetsHistoryAsync()
        {
            Mock <AssetService.AssetServiceClient> mockGrpcClient = new Mock <AssetService.AssetServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest
            {
                ParentAsProjectName = new ProjectName("[PROJECT]"),
                ContentType         = ContentType.Unspecified,
                ReadTimeWindow      = new TimeWindow(),
            };
            BatchGetAssetsHistoryResponse expectedResponse = new BatchGetAssetsHistoryResponse();

            mockGrpcClient.Setup(x => x.BatchGetAssetsHistoryAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <BatchGetAssetsHistoryResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            AssetServiceClient            client   = new AssetServiceClientImpl(mockGrpcClient.Object, null);
            BatchGetAssetsHistoryResponse response = await client.BatchGetAssetsHistoryAsync(request);

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