コード例 #1
0
        public void GetGameServerClusterRequestObject()
        {
            moq::Mock <GameServerClustersService.GameServerClustersServiceClient> mockGrpcClient = new moq::Mock <GameServerClustersService.GameServerClustersServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetGameServerClusterRequest request = new GetGameServerClusterRequest
            {
                GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster("[PROJECT]", "[LOCATION]", "[REALM]", "[CLUSTER]"),
            };
            GameServerCluster expectedResponse = new GameServerCluster
            {
                GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster("[PROJECT]", "[LOCATION]", "[REALM]", "[CLUSTER]"),
                CreateTime            = new wkt::Timestamp(),
                UpdateTime            = new wkt::Timestamp(),
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                ConnectionInfo = new GameServerClusterConnectionInfo(),
                Etag           = "etage8ad7218",
                Description    = "description2cf9da67",
            };

            mockGrpcClient.Setup(x => x.GetGameServerCluster(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            GameServerClustersServiceClient client = new GameServerClustersServiceClientImpl(mockGrpcClient.Object, null);
            GameServerCluster response             = client.GetGameServerCluster(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
    public GameServerCluster GetCluster(
        string projectId, string regionId, string realmId, string clusterId)
    {
        // Create the client.
        GameServerClustersServiceClient client = GameServerClustersServiceClient.Create();

        GetGameServerClusterRequest request = new GetGameServerClusterRequest
        {
            GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster(projectId, regionId, realmId, clusterId),
            View = GameServerClusterView.Full
        };

        // Make the request.
        GameServerCluster response = client.GetGameServerCluster(request);

        // You could write response.Name and response.ClusterState to the console
        // to see the installed versions of Agones and Kubernetes on the cluster.

        return(response);
    }
コード例 #3
0
        public async stt::Task GetGameServerClusterRequestObjectAsync()
        {
            moq::Mock <GameServerClustersService.GameServerClustersServiceClient> mockGrpcClient = new moq::Mock <GameServerClustersService.GameServerClustersServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetGameServerClusterRequest request = new GetGameServerClusterRequest
            {
                GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster("[PROJECT]", "[LOCATION]", "[REALM]", "[CLUSTER]"),
                View = GameServerClusterView.Basic,
            };
            GameServerCluster expectedResponse = new GameServerCluster
            {
                GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster("[PROJECT]", "[LOCATION]", "[REALM]", "[CLUSTER]"),
                CreateTime            = new wkt::Timestamp(),
                UpdateTime            = new wkt::Timestamp(),
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                ConnectionInfo = new GameServerClusterConnectionInfo(),
                Etag           = "etage8ad7218",
                Description    = "description2cf9da67",
                ClusterState   = new KubernetesClusterState(),
            };

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

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

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