Exemplo n.º 1
0
        public async stt::Task GetServiceRequestObjectAsync()
        {
            moq::Mock <Services.ServicesClient> mockGrpcClient = new moq::Mock <Services.ServicesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetServiceRequest request = new GetServiceRequest
            {
                Name = "name1c9368b0",
            };
            Service expectedResponse = new Service
            {
                Name            = "name1c9368b0",
                Id              = "id74b70bb8",
                Split           = new TrafficSplit(),
                NetworkSettings = new NetworkSettings(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public void GetServiceRequestObject()
        {
            moq::Mock <Services.ServicesClient> mockGrpcClient = new moq::Mock <Services.ServicesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetServiceRequest request = new GetServiceRequest
            {
                Name = "name1c9368b0",
            };
            Service expectedResponse = new Service
            {
                Name  = "name1c9368b0",
                Id    = "id74b70bb8",
                Split = new TrafficSplit(),
            };

            mockGrpcClient.Setup(x => x.GetService(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ServicesClient client   = new ServicesClientImpl(mockGrpcClient.Object, null);
            Service        response = client.GetService(request);

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