Esempio n. 1
0
        public async stt::Task GetServicePerimeterResourceNamesAsync()
        {
            moq::Mock <AccessContextManager.AccessContextManagerClient> mockGrpcClient = new moq::Mock <AccessContextManager.AccessContextManagerClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetServicePerimeterRequest request = new GetServicePerimeterRequest
            {
                ServicePerimeterName = ServicePerimeterName.FromAccessPolicyServicePerimeter("[ACCESS_POLICY]", "[SERVICE_PERIMETER]"),
            };
            ServicePerimeter expectedResponse = new ServicePerimeter
            {
                ServicePerimeterName = ServicePerimeterName.FromAccessPolicyServicePerimeter("[ACCESS_POLICY]", "[SERVICE_PERIMETER]"),
                Title                 = "title17dbd3d5",
                Description           = "description2cf9da67",
                CreateTime            = new wkt::Timestamp(),
                UpdateTime            = new wkt::Timestamp(),
                PerimeterType         = ServicePerimeter.Types.PerimeterType.Bridge,
                Status                = new ServicePerimeterConfig(),
                Spec                  = new ServicePerimeterConfig(),
                UseExplicitDryRunSpec = true,
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            ServicePerimeter responseCancellationToken = await client.GetServicePerimeterAsync(request.ServicePerimeterName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 2
0
        public void GetServicePerimeter()
        {
            moq::Mock <AccessContextManager.AccessContextManagerClient> mockGrpcClient = new moq::Mock <AccessContextManager.AccessContextManagerClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetServicePerimeterRequest request = new GetServicePerimeterRequest
            {
                ServicePerimeterName = ServicePerimeterName.FromAccessPolicyServicePerimeter("[ACCESS_POLICY]", "[SERVICE_PERIMETER]"),
            };
            ServicePerimeter expectedResponse = new ServicePerimeter
            {
                ServicePerimeterName = ServicePerimeterName.FromAccessPolicyServicePerimeter("[ACCESS_POLICY]", "[SERVICE_PERIMETER]"),
                Title                 = "title17dbd3d5",
                Description           = "description2cf9da67",
                CreateTime            = new wkt::Timestamp(),
                UpdateTime            = new wkt::Timestamp(),
                PerimeterType         = ServicePerimeter.Types.PerimeterType.Bridge,
                Status                = new ServicePerimeterConfig(),
                Spec                  = new ServicePerimeterConfig(),
                UseExplicitDryRunSpec = true,
            };

            mockGrpcClient.Setup(x => x.GetServicePerimeter(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            AccessContextManagerClient client   = new AccessContextManagerClientImpl(mockGrpcClient.Object, null);
            ServicePerimeter           response = client.GetServicePerimeter(request.Name);

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