コード例 #1
0
        public async stt::Task GetInventoryResourceNamesAsync()
        {
            moq::Mock <OsConfigZonalService.OsConfigZonalServiceClient> mockGrpcClient = new moq::Mock <OsConfigZonalService.OsConfigZonalServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetInventoryRequest request = new GetInventoryRequest
            {
                InventoryName = InventoryName.FromProjectLocationInstance("[PROJECT]", "[LOCATION]", "[INSTANCE]"),
            };
            Inventory expectedResponse = new Inventory
            {
                OsInfo = new Inventory.Types.OsInfo(),
                Items  =
                {
                    {
                        "key8a0b6e3c",
                        new Inventory.Types.Item()
                    },
                },
                InventoryName = InventoryName.FromProjectLocationInstance("[PROJECT]", "[LOCATION]", "[INSTANCE]"),
                UpdateTime    = new wkt::Timestamp(),
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Inventory responseCancellationToken = await client.GetInventoryAsync(request.InventoryName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
        public void GetInventoryResourceNames()
        {
            moq::Mock <OsConfigZonalService.OsConfigZonalServiceClient> mockGrpcClient = new moq::Mock <OsConfigZonalService.OsConfigZonalServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetInventoryRequest request = new GetInventoryRequest
            {
                InventoryName = InventoryName.FromProjectLocationInstance("[PROJECT]", "[LOCATION]", "[INSTANCE]"),
            };
            Inventory expectedResponse = new Inventory
            {
                OsInfo = new Inventory.Types.OsInfo(),
                Items  =
                {
                    {
                        "key8a0b6e3c",
                        new Inventory.Types.Item()
                    },
                },
                InventoryName = InventoryName.FromProjectLocationInstance("[PROJECT]", "[LOCATION]", "[INSTANCE]"),
                UpdateTime    = new wkt::Timestamp(),
            };

            mockGrpcClient.Setup(x => x.GetInventory(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            OsConfigZonalServiceClient client = new OsConfigZonalServiceClientImpl(mockGrpcClient.Object, null);
            Inventory response = client.GetInventory(request.InventoryName);

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