public async stt::Task GetRequestObjectAsync()
        {
            moq::Mock <InterconnectAttachments.InterconnectAttachmentsClient> mockGrpcClient = new moq::Mock <InterconnectAttachments.InterconnectAttachmentsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetInterconnectAttachmentRequest request = new GetInterconnectAttachmentRequest
            {
                Region  = "regionedb20d96",
                Project = "projectaa6ff846",
                InterconnectAttachment = "interconnect_attachmentc83a7a7c",
            };
            InterconnectAttachment expectedResponse = new InterconnectAttachment
            {
                Id   = 11672635353343658936UL,
                Mtu  = 1280318054,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                Type = "typee2cc9d59",
                CreationTimestamp      = "creation_timestamp235e59a1",
                DataplaneVersion       = -763719012,
                PartnerMetadata        = new InterconnectAttachmentPartnerMetadata(),
                EdgeAvailabilityDomain = "edge_availability_domainf7acc827",
                Encryption             = "encryption9174df5b",
                State                   = "state2e9ed39e",
                VlanTag8021Q            = 1290733749,
                Region                  = "regionedb20d96",
                Router                  = "routerd55c39f3",
                Bandwidth               = "bandwidth2b6c6736",
                OperationalStatus       = "operational_status14a476d9",
                Interconnect            = "interconnect253e8bf5",
                PrivateInterconnectInfo = new InterconnectAttachmentPrivateInfo(),
                CandidateSubnets        =
                {
                    "candidate_subnets3377adaa",
                },
                CloudRouterIpAddress    = "cloud_router_ip_address62b476a9",
                CustomerRouterIpAddress = "customer_router_ip_address819aa186",
                IpsecInternalAddresses  =
                {
                    "ipsec_internal_addresses8b47c5bb",
                },
                Description       = "description2cf9da67",
                PartnerAsn        = 6862354938501622805L,
                PairingKey        = "pairing_keyfe878c44",
                AdminEnabled      = true,
                SelfLink          = "self_link7e87f12d",
                SatisfiesPzs      = false,
                GoogleReferenceId = "google_reference_id815b6ab4",
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        public void GetRequestObject()
        {
            moq::Mock <InterconnectAttachments.InterconnectAttachmentsClient> mockGrpcClient = new moq::Mock <InterconnectAttachments.InterconnectAttachmentsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetInterconnectAttachmentRequest request = new GetInterconnectAttachmentRequest
            {
                Region  = "regionedb20d96",
                Project = "projectaa6ff846",
                InterconnectAttachment = "interconnect_attachmentc83a7a7c",
            };
            InterconnectAttachment expectedResponse = new InterconnectAttachment
            {
                Id   = 11672635353343658936UL,
                Mtu  = 1280318054,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                Type = InterconnectAttachment.Types.Type.PartnerProvider,
                CreationTimestamp      = "creation_timestamp235e59a1",
                DataplaneVersion       = -763719012,
                PartnerMetadata        = new InterconnectAttachmentPartnerMetadata(),
                EdgeAvailabilityDomain = InterconnectAttachment.Types.EdgeAvailabilityDomain.AvailabilityDomain1,
                Encryption             = InterconnectAttachment.Types.Encryption.None,
                State                   = InterconnectAttachment.Types.State.Unspecified,
                VlanTag8021Q            = 1290733749,
                Region                  = "regionedb20d96",
                Router                  = "routerd55c39f3",
                Bandwidth               = InterconnectAttachment.Types.Bandwidth.Bps500M,
                OperationalStatus       = InterconnectAttachment.Types.OperationalStatus.UndefinedOperationalStatus,
                Interconnect            = "interconnect253e8bf5",
                PrivateInterconnectInfo = new InterconnectAttachmentPrivateInfo(),
                CandidateSubnets        =
                {
                    "candidate_subnets3377adaa",
                },
                CloudRouterIpAddress    = "cloud_router_ip_address62b476a9",
                CustomerRouterIpAddress = "customer_router_ip_address819aa186",
                IpsecInternalAddresses  =
                {
                    "ipsec_internal_addresses8b47c5bb",
                },
                Description       = "description2cf9da67",
                PartnerAsn        = 6862354938501622805L,
                PairingKey        = "pairing_keyfe878c44",
                AdminEnabled      = true,
                SelfLink          = "self_link7e87f12d",
                SatisfiesPzs      = false,
                GoogleReferenceId = "google_reference_id815b6ab4",
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            InterconnectAttachmentsClient client   = new InterconnectAttachmentsClientImpl(mockGrpcClient.Object, null);
            InterconnectAttachment        response = client.Get(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task PatchRequestObjectAsync()
        {
            moq::Mock <InterconnectAttachments.InterconnectAttachmentsClient> mockGrpcClient = new moq::Mock <InterconnectAttachments.InterconnectAttachmentsClient>(moq::MockBehavior.Strict);
            PatchInterconnectAttachmentRequest request = new PatchInterconnectAttachmentRequest
            {
                RequestId = "request_id362c8df6",
                Region    = "regionedb20d96",
                InterconnectAttachmentResource = new InterconnectAttachment(),
                Project = "projectaa6ff846",
                InterconnectAttachment = "interconnect_attachmentc83a7a7c",
            };
            Operation expectedResponse = new Operation
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                User = "******",
                Zone = "zone255f4ea8",
                CreationTimestamp   = "creation_timestamp235e59a1",
                StartTime           = "start_timebd8dd9c4",
                OperationGroupId    = "operation_group_idd2040cf0",
                TargetLink          = "target_link9b435dc0",
                Progress            = 278622268,
                Error               = new Error(),
                EndTime             = "end_time89285d30",
                Region              = "regionedb20d96",
                OperationType       = "operation_typeece9e153",
                Status              = Operation.Types.Status.Pending,
                HttpErrorMessage    = "http_error_messageb5ef3c7f",
                TargetId            = 6263187990225347157UL,
                ClientOperationId   = "client_operation_id4e51b631",
                StatusMessage       = "status_message2c618f86",
                HttpErrorStatusCode = 1766362655,
                Description         = "description2cf9da67",
                InsertTime          = "insert_time7467185a",
                SelfLink            = "self_link7e87f12d",
                Warnings            = { new Warnings(), },
            };

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

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

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