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();
        }
        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();
        }
예제 #3
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();
        }