Esempio n. 1
0
        public async stt::Task CreateFeedAsync()
        {
            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);
            CreateFeedRequest request = new CreateFeedRequest
            {
                Parent = "parent7858e4d0",
            };
            Feed expectedResponse = new Feed
            {
                FeedName   = FeedName.FromProjectFeed("[PROJECT]", "[FEED]"),
                AssetNames =
                {
                    "asset_namese42cd316",
                },
                AssetTypes =
                {
                    "asset_types44c0f429",
                },
                ContentType      = ContentType.IamPolicy,
                FeedOutputConfig = new FeedOutputConfig(),
                Condition        = new gt::Expr(),
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Feed responseCancellationToken = await client.CreateFeedAsync(request.Parent, st::CancellationToken.None);

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

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            CreateFeedRequest request = new CreateFeedRequest
            {
                Parent = "parent-995424086",
                FeedId = "feedId-976011428",
                Feed   = new Feed(),
            };
            Feed expectedResponse = new Feed
            {
                Name = "name3373707",
            };

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

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