Ejemplo n.º 1
0
        public void GetSpecialistPoolRequestObject()
        {
            moq::Mock <SpecialistPoolService.SpecialistPoolServiceClient> mockGrpcClient = new moq::Mock <SpecialistPoolService.SpecialistPoolServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetSpecialistPoolRequest request = new GetSpecialistPoolRequest
            {
                SpecialistPoolName = SpecialistPoolName.FromProjectLocationSpecialistPool("[PROJECT]", "[LOCATION]", "[SPECIALIST_POOL]"),
            };
            SpecialistPool expectedResponse = new SpecialistPool
            {
                SpecialistPoolName      = SpecialistPoolName.FromProjectLocationSpecialistPool("[PROJECT]", "[LOCATION]", "[SPECIALIST_POOL]"),
                DisplayName             = "display_name137f65c2",
                SpecialistManagersCount = 1389839351,
                SpecialistManagerEmails =
                {
                    "specialist_manager_emails54da434d",
                },
                PendingDataLabelingJobs =
                {
                    "pending_data_labeling_jobsd91cc38b",
                },
                SpecialistWorkerEmails =
                {
                    "specialist_worker_emailsac41cb4d",
                },
            };

            mockGrpcClient.Setup(x => x.GetSpecialistPool(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            SpecialistPoolServiceClient client = new SpecialistPoolServiceClientImpl(mockGrpcClient.Object, null);
            SpecialistPool response            = client.GetSpecialistPool(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for UpdateSpecialistPool</summary>
        public void UpdateSpecialistPoolRequestObject()
        {
            // Snippet: UpdateSpecialistPool(UpdateSpecialistPoolRequest, CallSettings)
            // Create client
            SpecialistPoolServiceClient specialistPoolServiceClient = SpecialistPoolServiceClient.Create();
            // Initialize request argument(s)
            UpdateSpecialistPoolRequest request = new UpdateSpecialistPoolRequest
            {
                SpecialistPool = new SpecialistPool(),
                UpdateMask     = new FieldMask(),
            };
            // Make the request
            Operation <SpecialistPool, UpdateSpecialistPoolOperationMetadata> response = specialistPoolServiceClient.UpdateSpecialistPool(request);

            // Poll until the returned long-running operation is complete
            Operation <SpecialistPool, UpdateSpecialistPoolOperationMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            SpecialistPool result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <SpecialistPool, UpdateSpecialistPoolOperationMetadata> retrievedResponse = specialistPoolServiceClient.PollOnceUpdateSpecialistPool(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                SpecialistPool retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
        /// <summary>Snippet for UpdateSpecialistPoolAsync</summary>
        public async Task UpdateSpecialistPoolAsync()
        {
            // Snippet: UpdateSpecialistPoolAsync(SpecialistPool, FieldMask, CallSettings)
            // Additional: UpdateSpecialistPoolAsync(SpecialistPool, FieldMask, CancellationToken)
            // Create client
            SpecialistPoolServiceClient specialistPoolServiceClient = await SpecialistPoolServiceClient.CreateAsync();

            // Initialize request argument(s)
            SpecialistPool specialistPool = new SpecialistPool();
            FieldMask      updateMask     = new FieldMask();
            // Make the request
            Operation <SpecialistPool, UpdateSpecialistPoolOperationMetadata> response = await specialistPoolServiceClient.UpdateSpecialistPoolAsync(specialistPool, updateMask);

            // Poll until the returned long-running operation is complete
            Operation <SpecialistPool, UpdateSpecialistPoolOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            SpecialistPool result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <SpecialistPool, UpdateSpecialistPoolOperationMetadata> retrievedResponse = await specialistPoolServiceClient.PollOnceUpdateSpecialistPoolAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                SpecialistPool retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
        /// <summary>Snippet for CreateSpecialistPool</summary>
        public void CreateSpecialistPoolResourceNames()
        {
            // Snippet: CreateSpecialistPool(LocationName, SpecialistPool, CallSettings)
            // Create client
            SpecialistPoolServiceClient specialistPoolServiceClient = SpecialistPoolServiceClient.Create();
            // Initialize request argument(s)
            LocationName   parent         = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            SpecialistPool specialistPool = new SpecialistPool();
            // Make the request
            Operation <SpecialistPool, CreateSpecialistPoolOperationMetadata> response = specialistPoolServiceClient.CreateSpecialistPool(parent, specialistPool);

            // Poll until the returned long-running operation is complete
            Operation <SpecialistPool, CreateSpecialistPoolOperationMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            SpecialistPool result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <SpecialistPool, CreateSpecialistPoolOperationMetadata> retrievedResponse = specialistPoolServiceClient.PollOnceCreateSpecialistPool(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                SpecialistPool retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
        /// <summary>Snippet for CreateSpecialistPoolAsync</summary>
        public async Task CreateSpecialistPoolRequestObjectAsync()
        {
            // Snippet: CreateSpecialistPoolAsync(CreateSpecialistPoolRequest, CallSettings)
            // Additional: CreateSpecialistPoolAsync(CreateSpecialistPoolRequest, CancellationToken)
            // Create client
            SpecialistPoolServiceClient specialistPoolServiceClient = await SpecialistPoolServiceClient.CreateAsync();

            // Initialize request argument(s)
            CreateSpecialistPoolRequest request = new CreateSpecialistPoolRequest
            {
                ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                SpecialistPool       = new SpecialistPool(),
            };
            // Make the request
            Operation <SpecialistPool, CreateSpecialistPoolOperationMetadata> response = await specialistPoolServiceClient.CreateSpecialistPoolAsync(request);

            // Poll until the returned long-running operation is complete
            Operation <SpecialistPool, CreateSpecialistPoolOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            SpecialistPool result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <SpecialistPool, CreateSpecialistPoolOperationMetadata> retrievedResponse = await specialistPoolServiceClient.PollOnceCreateSpecialistPoolAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                SpecialistPool retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a new game using the provided GameConfiguration. Calling this constructor will trigger
        /// map generation and generate the map based on the GameConfiguration that was passed into the game.
        /// </summary>
        /// <param name="gameConfiguration">Settings that determine how the game should be configured during generation.</param>
        public Game(GameConfiguration gameConfiguration)
        {
            SeededRandom = new SeededRandom(gameConfiguration.MapConfiguration.Seed);

            // Creates a new game state and makes a time machine to reference the state
            GameState.GameState state = new GameState.GameState(gameConfiguration);
            TimeMachine = new TimeMachine(state);

            // Creates the map generator with a random seed
            MapGenerator mapGenerator = new MapGenerator(gameConfiguration.MapConfiguration, state.GetPlayers());

            // Generate the map
            List <Outpost> generatedOutposts = mapGenerator.GenerateMap();

            // Add the outposts to the map
            state.GetOutposts().AddRange(generatedOutposts);

            // Populate the specialist pool
            SpecialistPool = new SpecialistPool(SeededRandom, gameConfiguration.GameSettings.AllowedSpecialists.ToList());

            // All owned factories should start producing drillers
            foreach (Outpost o in generatedOutposts)
            {
                if (o is Factory && o.GetComponent <DrillerCarrier>().GetOwner() != null)
                {
                    Factory f = (Factory)o;
                    TimeMachine.AddEvent(new FactoryProduction(f, f.GetTicksToFirstProduction()));
                }
            }
        }
Ejemplo n.º 7
0
        public async stt::Task GetSpecialistPoolRequestObjectAsync()
        {
            moq::Mock <SpecialistPoolService.SpecialistPoolServiceClient> mockGrpcClient = new moq::Mock <SpecialistPoolService.SpecialistPoolServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetSpecialistPoolRequest request = new GetSpecialistPoolRequest
            {
                SpecialistPoolName = SpecialistPoolName.FromProjectLocationSpecialistPool("[PROJECT]", "[LOCATION]", "[SPECIALIST_POOL]"),
            };
            SpecialistPool expectedResponse = new SpecialistPool
            {
                SpecialistPoolName      = SpecialistPoolName.FromProjectLocationSpecialistPool("[PROJECT]", "[LOCATION]", "[SPECIALIST_POOL]"),
                DisplayName             = "display_name137f65c2",
                SpecialistManagersCount = 1389839351,
                SpecialistManagerEmails =
                {
                    "specialist_manager_emails54da434d",
                },
                PendingDataLabelingJobs =
                {
                    "pending_data_labeling_jobsd91cc38b",
                },
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for GetSpecialistPool</summary>
 public void GetSpecialistPoolResourceNames()
 {
     // Snippet: GetSpecialistPool(SpecialistPoolName, CallSettings)
     // Create client
     SpecialistPoolServiceClient specialistPoolServiceClient = SpecialistPoolServiceClient.Create();
     // Initialize request argument(s)
     SpecialistPoolName name = SpecialistPoolName.FromProjectLocationSpecialistPool("[PROJECT]", "[LOCATION]", "[SPECIALIST_POOL]");
     // Make the request
     SpecialistPool response = specialistPoolServiceClient.GetSpecialistPool(name);
     // End snippet
 }
 /// <summary>Snippet for GetSpecialistPool</summary>
 public void GetSpecialistPool()
 {
     // Snippet: GetSpecialistPool(string, CallSettings)
     // Create client
     SpecialistPoolServiceClient specialistPoolServiceClient = SpecialistPoolServiceClient.Create();
     // Initialize request argument(s)
     string name = "projects/[PROJECT]/locations/[LOCATION]/specialistPools/[SPECIALIST_POOL]";
     // Make the request
     SpecialistPool response = specialistPoolServiceClient.GetSpecialistPool(name);
     // End snippet
 }
        /// <summary>Snippet for GetSpecialistPoolAsync</summary>
        public async Task GetSpecialistPoolResourceNamesAsync()
        {
            // Snippet: GetSpecialistPoolAsync(SpecialistPoolName, CallSettings)
            // Additional: GetSpecialistPoolAsync(SpecialistPoolName, CancellationToken)
            // Create client
            SpecialistPoolServiceClient specialistPoolServiceClient = await SpecialistPoolServiceClient.CreateAsync();

            // Initialize request argument(s)
            SpecialistPoolName name = SpecialistPoolName.FromProjectLocationSpecialistPool("[PROJECT]", "[LOCATION]", "[SPECIALIST_POOL]");
            // Make the request
            SpecialistPool response = await specialistPoolServiceClient.GetSpecialistPoolAsync(name);

            // End snippet
        }
        /// <summary>Snippet for GetSpecialistPoolAsync</summary>
        public async Task GetSpecialistPoolAsync()
        {
            // Snippet: GetSpecialistPoolAsync(string, CallSettings)
            // Additional: GetSpecialistPoolAsync(string, CancellationToken)
            // Create client
            SpecialistPoolServiceClient specialistPoolServiceClient = await SpecialistPoolServiceClient.CreateAsync();

            // Initialize request argument(s)
            string name = "projects/[PROJECT]/locations/[LOCATION]/specialistPools/[SPECIALIST_POOL]";
            // Make the request
            SpecialistPool response = await specialistPoolServiceClient.GetSpecialistPoolAsync(name);

            // End snippet
        }
 /// <summary>Snippet for GetSpecialistPool</summary>
 public void GetSpecialistPoolRequestObject()
 {
     // Snippet: GetSpecialistPool(GetSpecialistPoolRequest, CallSettings)
     // Create client
     SpecialistPoolServiceClient specialistPoolServiceClient = SpecialistPoolServiceClient.Create();
     // Initialize request argument(s)
     GetSpecialistPoolRequest request = new GetSpecialistPoolRequest
     {
         SpecialistPoolName = SpecialistPoolName.FromProjectLocationSpecialistPool("[PROJECT]", "[LOCATION]", "[SPECIALIST_POOL]"),
     };
     // Make the request
     SpecialistPool response = specialistPoolServiceClient.GetSpecialistPool(request);
     // End snippet
 }