Пример #1
0
        public async stt::Task GetDiagnosticsAsync()
        {
            moq::Mock <Interconnects.InterconnectsClient> mockGrpcClient = new moq::Mock <Interconnects.InterconnectsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetDiagnosticsInterconnectRequest request = new GetDiagnosticsInterconnectRequest
            {
                Interconnect = "interconnect253e8bf5",
                Project      = "projectaa6ff846",
            };
            InterconnectsGetDiagnosticsResponse expectedResponse = new InterconnectsGetDiagnosticsResponse
            {
                Result = new InterconnectDiagnostics(),
            };

            mockGrpcClient.Setup(x => x.GetDiagnosticsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <InterconnectsGetDiagnosticsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            InterconnectsClient client = new InterconnectsClientImpl(mockGrpcClient.Object, null);
            InterconnectsGetDiagnosticsResponse responseCallSettings = await client.GetDiagnosticsAsync(request.Project, request.Interconnect, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            InterconnectsGetDiagnosticsResponse responseCancellationToken = await client.GetDiagnosticsAsync(request.Project, request.Interconnect, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Пример #2
0
        public async stt::Task GetRequestObjectAsync()
        {
            moq::Mock <Interconnects.InterconnectsClient> mockGrpcClient = new moq::Mock <Interconnects.InterconnectsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetInterconnectRequest request = new GetInterconnectRequest
            {
                Interconnect = "interconnect253e8bf5",
                Project      = "projectaa6ff846",
            };
            Interconnect expectedResponse = new Interconnect
            {
                Id                 = 11672635353343658936UL,
                Kind               = "kindf7aa39d9",
                Name               = "name1c9368b0",
                CustomerName       = "customer_name2ace137a",
                NocContactEmail    = "noc_contact_email1d95c1b6",
                CreationTimestamp  = "creation_timestamp235e59a1",
                RequestedLinkCount = 2020560861,
                State              = Interconnect.Types.State.UndefinedState,
                CircuitInfos       =
                {
                    new InterconnectCircuitInfo(),
                },
                OperationalStatus = Interconnect.Types.OperationalStatus.UndefinedOperationalStatus,
                PeerIpAddress     = "peer_ip_address07617b81",
                ExpectedOutages   =
                {
                    new InterconnectOutageNotification(),
                },
                Location                = "locatione09d18d5",
                ProvisionedLinkCount    = 1441690745,
                Description             = "description2cf9da67",
                InterconnectAttachments =
                {
                    "interconnect_attachmentsdc10a889",
                },
                GoogleIpAddress   = "google_ip_address246d4427",
                AdminEnabled      = true,
                SelfLink          = "self_link7e87f12d",
                SatisfiesPzs      = false,
                InterconnectType  = Interconnect.Types.InterconnectType.Partner,
                LinkType          = Interconnect.Types.LinkType.UndefinedLinkType,
                GoogleReferenceId = "google_reference_id815b6ab4",
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Пример #3
0
        public void GetRequestObject()
        {
            moq::Mock <Interconnects.InterconnectsClient> mockGrpcClient = new moq::Mock <Interconnects.InterconnectsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetInterconnectRequest request = new GetInterconnectRequest
            {
                Interconnect = "interconnect253e8bf5",
                Project      = "projectaa6ff846",
            };
            Interconnect expectedResponse = new Interconnect
            {
                Id                 = 11672635353343658936UL,
                Kind               = "kindf7aa39d9",
                Name               = "name1c9368b0",
                CustomerName       = "customer_name2ace137a",
                NocContactEmail    = "noc_contact_email1d95c1b6",
                CreationTimestamp  = "creation_timestamp235e59a1",
                RequestedLinkCount = 2020560861,
                State              = "state2e9ed39e",
                CircuitInfos       =
                {
                    new InterconnectCircuitInfo(),
                },
                OperationalStatus = "operational_status14a476d9",
                PeerIpAddress     = "peer_ip_address07617b81",
                ExpectedOutages   =
                {
                    new InterconnectOutageNotification(),
                },
                Location                = "locatione09d18d5",
                ProvisionedLinkCount    = 1441690745,
                Description             = "description2cf9da67",
                InterconnectAttachments =
                {
                    "interconnect_attachmentsdc10a889",
                },
                GoogleIpAddress   = "google_ip_address246d4427",
                AdminEnabled      = true,
                SelfLink          = "self_link7e87f12d",
                SatisfiesPzs      = false,
                InterconnectType  = "interconnect_type87ba691d",
                LinkType          = "link_type65f7baf6",
                GoogleReferenceId = "google_reference_id815b6ab4",
            };

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

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task PatchRequestObjectAsync()
        {
            moq::Mock <Interconnects.InterconnectsClient> mockGrpcClient = new moq::Mock <Interconnects.InterconnectsClient>(moq::MockBehavior.Strict);
            PatchInterconnectRequest request = new PatchInterconnectRequest
            {
                RequestId            = "request_id362c8df6",
                Interconnect         = "interconnect253e8bf5",
                Project              = "projectaa6ff846",
                InterconnectResource = new Interconnect(),
            };
            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));
            InterconnectsClient client = new InterconnectsClientImpl(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();
        }
        public void GetDiagnostics()
        {
            moq::Mock <Interconnects.InterconnectsClient> mockGrpcClient = new moq::Mock <Interconnects.InterconnectsClient>(moq::MockBehavior.Strict);
            GetDiagnosticsInterconnectRequest             request        = new GetDiagnosticsInterconnectRequest
            {
                Interconnect = "interconnect253e8bf5",
                Project      = "projectaa6ff846",
            };
            InterconnectsGetDiagnosticsResponse expectedResponse = new InterconnectsGetDiagnosticsResponse
            {
                Result = new InterconnectDiagnostics(),
            };

            mockGrpcClient.Setup(x => x.GetDiagnostics(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            InterconnectsClient client = new InterconnectsClientImpl(mockGrpcClient.Object, null);
            InterconnectsGetDiagnosticsResponse response = client.GetDiagnostics(request.Project, request.Interconnect);

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