Esempio n. 1
0
        public void Get()
        {
            moq::Mock <LicenseCodes.LicenseCodesClient> mockGrpcClient = new moq::Mock <LicenseCodes.LicenseCodesClient>(moq::MockBehavior.Strict);
            GetLicenseCodeRequest request = new GetLicenseCodeRequest
            {
                LicenseCode = "license_code196a50c0",
                Project     = "projectaa6ff846",
            };
            LicenseCode expectedResponse = new LicenseCode
            {
                Id                = "id74b70bb8",
                Kind              = "kindf7aa39d9",
                Name              = "name1c9368b0",
                Transferable      = false,
                CreationTimestamp = "creation_timestamp235e59a1",
                LicenseAlias      =
                {
                    new LicenseCodeLicenseAlias(),
                },
                State       = LicenseCode.Types.State.UndefinedState,
                Description = "description2cf9da67",
                SelfLink    = "self_link7e87f12d",
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            LicenseCodesClient client   = new LicenseCodesClientImpl(mockGrpcClient.Object, null);
            LicenseCode        response = client.Get(request.Project, request.LicenseCode);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 2
0
        public async stt::Task TestIamPermissionsAsync()
        {
            moq::Mock <LicenseCodes.LicenseCodesClient> mockGrpcClient = new moq::Mock <LicenseCodes.LicenseCodesClient>(moq::MockBehavior.Strict);
            TestIamPermissionsLicenseCodeRequest        request        = new TestIamPermissionsLicenseCodeRequest
            {
                TestPermissionsRequestResource = new TestPermissionsRequest(),
                Resource = "resource164eab96",
                Project  = "projectaa6ff846",
            };
            TestPermissionsResponse expectedResponse = new TestPermissionsResponse
            {
                Permissions =
                {
                    "permissions535a2741",
                },
            };

            mockGrpcClient.Setup(x => x.TestIamPermissionsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <TestPermissionsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            LicenseCodesClient      client = new LicenseCodesClientImpl(mockGrpcClient.Object, null);
            TestPermissionsResponse responseCallSettings = await client.TestIamPermissionsAsync(request.Project, request.Resource, request.TestPermissionsRequestResource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            TestPermissionsResponse responseCancellationToken = await client.TestIamPermissionsAsync(request.Project, request.Resource, request.TestPermissionsRequestResource, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 3
0
        public async stt::Task GetRequestObjectAsync()
        {
            moq::Mock <LicenseCodes.LicenseCodesClient> mockGrpcClient = new moq::Mock <LicenseCodes.LicenseCodesClient>(moq::MockBehavior.Strict);
            GetLicenseCodeRequest request = new GetLicenseCodeRequest
            {
                LicenseCode = "license_code196a50c0",
                Project     = "projectaa6ff846",
            };
            LicenseCode expectedResponse = new LicenseCode
            {
                Id                = "id74b70bb8",
                Kind              = "kindf7aa39d9",
                Name              = "name1c9368b0",
                Transferable      = false,
                CreationTimestamp = "creation_timestamp235e59a1",
                LicenseAlias      =
                {
                    new LicenseCodeLicenseAlias(),
                },
                State       = LicenseCode.Types.State.UndefinedState,
                Description = "description2cf9da67",
                SelfLink    = "self_link7e87f12d",
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 4
0
        public void TestIamPermissions()
        {
            moq::Mock <LicenseCodes.LicenseCodesClient> mockGrpcClient = new moq::Mock <LicenseCodes.LicenseCodesClient>(moq::MockBehavior.Strict);
            TestIamPermissionsLicenseCodeRequest        request        = new TestIamPermissionsLicenseCodeRequest
            {
                TestPermissionsRequestResource = new TestPermissionsRequest(),
                Resource = "resource164eab96",
                Project  = "projectaa6ff846",
            };
            TestPermissionsResponse expectedResponse = new TestPermissionsResponse
            {
                Permissions =
                {
                    "permissions535a2741",
                },
            };

            mockGrpcClient.Setup(x => x.TestIamPermissions(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            LicenseCodesClient      client   = new LicenseCodesClientImpl(mockGrpcClient.Object, null);
            TestPermissionsResponse response = client.TestIamPermissions(request.Project, request.Resource, request.TestPermissionsRequestResource);

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