コード例 #1
0
        public void CreateClientEvent()
        {
            moq::Mock <EventService.EventServiceClient> mockGrpcClient = new moq::Mock <EventService.EventServiceClient>(moq::MockBehavior.Strict);
            CreateClientEventRequest request = new CreateClientEventRequest
            {
                ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                ClientEvent        = new ClientEvent(),
            };
            ClientEvent expectedResponse = new ClientEvent
            {
                RequestId    = "request_id362c8df6",
                EventId      = "event_idaccf3744",
                CreateTime   = new wkt::Timestamp(),
                JobEvent     = new JobEvent(),
                ProfileEvent = new ProfileEvent(),
                EventNotes   = "event_notes102ba330",
            };

            mockGrpcClient.Setup(x => x.CreateClientEvent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            EventServiceClient client   = new EventServiceClientImpl(mockGrpcClient.Object, null);
            ClientEvent        response = client.CreateClientEvent(request.Parent, request.ClientEvent);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
        public async stt::Task CreateClientEventRequestObjectAsync()
        {
            moq::Mock <EventService.EventServiceClient> mockGrpcClient = new moq::Mock <EventService.EventServiceClient>(moq::MockBehavior.Strict);
            CreateClientEventRequest request = new CreateClientEventRequest
            {
                ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                ClientEvent        = new ClientEvent(),
            };
            ClientEvent expectedResponse = new ClientEvent
            {
                RequestId    = "request_id362c8df6",
                EventId      = "event_idaccf3744",
                CreateTime   = new wkt::Timestamp(),
                JobEvent     = new JobEvent(),
                ProfileEvent = new ProfileEvent(),
                EventNotes   = "event_notes102ba330",
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #3
0
        public async Task CreateClientEventAsync()
        {
            Mock <EventService.EventServiceClient> mockGrpcClient = new Mock <EventService.EventServiceClient>(MockBehavior.Strict);
            CreateClientEventRequest expectedRequest = new CreateClientEventRequest
            {
                ParentAsTenantOrProjectNameOneof = TenantOrProjectNameOneof.From(new TenantName("[PROJECT]", "[TENANT]")),
                ClientEvent = new ClientEvent(),
            };
            ClientEvent expectedResponse = new ClientEvent
            {
                RequestId  = "requestId37109963",
                EventId    = "eventId278118624",
                EventNotes = "eventNotes445073628",
            };

            mockGrpcClient.Setup(x => x.CreateClientEventAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <ClientEvent>(Task.FromResult(expectedResponse), null, null, null, null));
            EventServiceClient       client = new EventServiceClientImpl(mockGrpcClient.Object, null);
            TenantOrProjectNameOneof parent = TenantOrProjectNameOneof.From(new TenantName("[PROJECT]", "[TENANT]"));
            ClientEvent clientEvent         = new ClientEvent();
            ClientEvent response            = await client.CreateClientEventAsync(parent, clientEvent);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #4
0
        public async Task CreateClientEventAsync()
        {
            Mock <EventService.EventServiceClient> mockGrpcClient = new Mock <EventService.EventServiceClient>(MockBehavior.Strict);
            CreateClientEventRequest expectedRequest = new CreateClientEventRequest
            {
                Parent      = new ProjectName("[PROJECT]").ToString(),
                ClientEvent = new ClientEvent(),
            };
            ClientEvent expectedResponse = new ClientEvent
            {
                RequestId     = "requestId37109963",
                EventId       = "eventId278118624",
                ParentEventId = "parentEventId-436467499",
            };

            mockGrpcClient.Setup(x => x.CreateClientEventAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <ClientEvent>(Task.FromResult(expectedResponse), null, null, null, null));
            EventServiceClient client          = new EventServiceClientImpl(mockGrpcClient.Object, null);
            string             formattedParent = new ProjectName("[PROJECT]").ToString();
            ClientEvent        clientEvent     = new ClientEvent();
            ClientEvent        response        = await client.CreateClientEventAsync(formattedParent, clientEvent);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #5
0
        public void CreateClientEvent()
        {
            Mock <EventService.EventServiceClient> mockGrpcClient = new Mock <EventService.EventServiceClient>(MockBehavior.Strict);
            CreateClientEventRequest expectedRequest = new CreateClientEventRequest
            {
                ParentAsProjectName = new ProjectName("[PROJECT]"),
                ClientEvent         = new ClientEvent(),
            };
            ClientEvent expectedResponse = new ClientEvent
            {
                RequestId     = "requestId37109963",
                EventId       = "eventId278118624",
                ParentEventId = "parentEventId-436467499",
            };

            mockGrpcClient.Setup(x => x.CreateClientEvent(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            EventServiceClient client      = new EventServiceClientImpl(mockGrpcClient.Object, null);
            ProjectName        parent      = new ProjectName("[PROJECT]");
            ClientEvent        clientEvent = new ClientEvent();
            ClientEvent        response    = client.CreateClientEvent(parent, clientEvent);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #6
0
        public void CreateClientEvent2()
        {
            Mock <EventService.EventServiceClient> mockGrpcClient = new Mock <EventService.EventServiceClient>(MockBehavior.Strict);
            CreateClientEventRequest request = new CreateClientEventRequest
            {
                ParentAsTenantOrProjectNameOneof = TenantOrProjectNameOneof.From(new TenantName("[PROJECT]", "[TENANT]")),
                ClientEvent = new ClientEvent(),
            };
            ClientEvent expectedResponse = new ClientEvent
            {
                RequestId  = "requestId37109963",
                EventId    = "eventId278118624",
                EventNotes = "eventNotes445073628",
            };

            mockGrpcClient.Setup(x => x.CreateClientEvent(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            EventServiceClient client   = new EventServiceClientImpl(mockGrpcClient.Object, null);
            ClientEvent        response = client.CreateClientEvent(request);

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