Ejemplo n.º 1
0
        public async stt::Task GetSharedSetRequestObjectAsync()
        {
            moq::Mock <SharedSetService.SharedSetServiceClient> mockGrpcClient = new moq::Mock <SharedSetService.SharedSetServiceClient>(moq::MockBehavior.Strict);
            GetSharedSetRequest request = new GetSharedSetRequest
            {
                ResourceNameAsSharedSetName = gagvr::SharedSetName.FromCustomerSharedSet("[CUSTOMER]", "[SHARED_SET]"),
            };
            gagvr::SharedSet expectedResponse = new gagvr::SharedSet
            {
                ResourceNameAsSharedSetName = gagvr::SharedSetName.FromCustomerSharedSet("[CUSTOMER]", "[SHARED_SET]"),
                Id             = -6774108720365892680L,
                Type           = gagve::SharedSetTypeEnum.Types.SharedSetType.NegativePlacements,
                SharedSetName  = gagvr::SharedSetName.FromCustomerSharedSet("[CUSTOMER]", "[SHARED_SET]"),
                Status         = gagve::SharedSetStatusEnum.Types.SharedSetStatus.Enabled,
                MemberCount    = -5151590354343439845L,
                ReferenceCount = -8440758895662409664L,
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::SharedSet responseCancellationToken = await client.GetSharedSetAsync(request, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task GetSharedSetAsync2()
        {
            Mock <SharedSetService.SharedSetServiceClient> mockGrpcClient = new Mock <SharedSetService.SharedSetServiceClient>(MockBehavior.Strict);
            GetSharedSetRequest request = new GetSharedSetRequest
            {
                ResourceName = new SharedSetName("[CUSTOMER]", "[SHARED_SET]").ToString(),
            };
            SharedSet expectedResponse = new SharedSet
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetSharedSetAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <SharedSet>(Task.FromResult(expectedResponse), null, null, null, null));
            SharedSetServiceClient client = new SharedSetServiceClientImpl(mockGrpcClient.Object, null);
            SharedSet response            = await client.GetSharedSetAsync(request);

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