Exemple #1
0
        public async stt::Task GetTriggerRequestObjectAsync()
        {
            moq::Mock <Eventarc.EventarcClient> mockGrpcClient = new moq::Mock <Eventarc.EventarcClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTriggerRequest request = new GetTriggerRequest
            {
                TriggerName = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"),
            };
            Trigger expectedResponse = new Trigger
            {
                TriggerName  = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"),
                Uid          = "uida2d37198",
                CreateTime   = new wkt::Timestamp(),
                UpdateTime   = new wkt::Timestamp(),
                EventFilters = { new EventFilter(), },
                ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
                Destination = new Destination(),
                Transport   = new Transport(),
                Labels      =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Etag = "etage8ad7218",
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemple #2
0
        public void GetTriggerResourceNames()
        {
            moq::Mock <Eventarc.EventarcClient> mockGrpcClient = new moq::Mock <Eventarc.EventarcClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTriggerRequest request = new GetTriggerRequest
            {
                TriggerName = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"),
            };
            Trigger expectedResponse = new Trigger
            {
                TriggerName  = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"),
                Uid          = "uida2d37198",
                CreateTime   = new wkt::Timestamp(),
                UpdateTime   = new wkt::Timestamp(),
                EventFilters = { new EventFilter(), },
                ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
                Destination = new Destination(),
                Transport   = new Transport(),
                Labels      =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Etag = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetTrigger(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            EventarcClient client   = new EventarcClientImpl(mockGrpcClient.Object, null);
            Trigger        response = client.GetTrigger(request.TriggerName);

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