Exemplo n.º 1
0
        public async stt::Task GetVulnerabilityReportResourceNamesAsync()
        {
            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);
            GetVulnerabilityReportRequest request = new GetVulnerabilityReportRequest
            {
                VulnerabilityReportName = VulnerabilityReportName.FromProjectLocationInstance("[PROJECT]", "[LOCATION]", "[INSTANCE]"),
            };
            VulnerabilityReport expectedResponse = new VulnerabilityReport
            {
                VulnerabilityReportName = VulnerabilityReportName.FromProjectLocationInstance("[PROJECT]", "[LOCATION]", "[INSTANCE]"),
                Vulnerabilities         =
                {
                    new VulnerabilityReport.Types.Vulnerability(),
                },
                UpdateTime = new wkt::Timestamp(),
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            VulnerabilityReport responseCancellationToken = await client.GetVulnerabilityReportAsync(request.VulnerabilityReportName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public void GetVulnerabilityReportResourceNames()
        {
            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);
            GetVulnerabilityReportRequest request = new GetVulnerabilityReportRequest
            {
                VulnerabilityReportName = VulnerabilityReportName.FromProjectLocationInstance("[PROJECT]", "[LOCATION]", "[INSTANCE]"),
            };
            VulnerabilityReport expectedResponse = new VulnerabilityReport
            {
                VulnerabilityReportName = VulnerabilityReportName.FromProjectLocationInstance("[PROJECT]", "[LOCATION]", "[INSTANCE]"),
                Vulnerabilities         =
                {
                    new VulnerabilityReport.Types.Vulnerability(),
                },
                UpdateTime = new wkt::Timestamp(),
            };

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

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