Example #1
0
        public void GetTagValue()
        {
            moq::Mock <TagValues.TagValuesClient> mockGrpcClient = new moq::Mock <TagValues.TagValuesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTagValueRequest request = new GetTagValueRequest
            {
                TagValueName = TagValueName.FromTagValue("[TAG_VALUE]"),
            };
            TagValue expectedResponse = new TagValue
            {
                TagValueName   = TagValueName.FromTagValue("[TAG_VALUE]"),
                Parent         = "parent7858e4d0",
                ShortName      = "short_namec7ba9846",
                NamespacedName = "namespaced_namea4453147",
                Description    = "description2cf9da67",
                CreateTime     = new wkt::Timestamp(),
                UpdateTime     = new wkt::Timestamp(),
                Etag           = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetTagValue(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TagValuesClient client   = new TagValuesClientImpl(mockGrpcClient.Object, null);
            TagValue        response = client.GetTagValue(request.Name);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #2
0
        public async stt::Task GetTagValueRequestObjectAsync()
        {
            moq::Mock <TagValues.TagValuesClient> mockGrpcClient = new moq::Mock <TagValues.TagValuesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTagValueRequest request = new GetTagValueRequest
            {
                TagValueName = TagValueName.FromTagValue("[TAG_VALUE]"),
            };
            TagValue expectedResponse = new TagValue
            {
                TagValueName   = TagValueName.FromTagValue("[TAG_VALUE]"),
                Parent         = "parent7858e4d0",
                ShortName      = "short_namec7ba9846",
                NamespacedName = "namespaced_namea4453147",
                Description    = "description2cf9da67",
                CreateTime     = new wkt::Timestamp(),
                UpdateTime     = new wkt::Timestamp(),
                Etag           = "etage8ad7218",
            };

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

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

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