Пример #1
0
        public void ReportErrorEvent2()
        {
            Mock <ReportErrorsService.ReportErrorsServiceClient> mockGrpcClient = new Mock <ReportErrorsService.ReportErrorsServiceClient>(MockBehavior.Strict);
            ReportErrorEventRequest request = new ReportErrorEventRequest
            {
                ProjectNameAsProjectName = new ProjectName("[PROJECT]"),
                Event = new ReportedErrorEvent(),
            };
            ReportErrorEventResponse expectedResponse = new ReportErrorEventResponse();

            mockGrpcClient.Setup(x => x.ReportErrorEvent(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            ReportErrorsServiceClient client   = new ReportErrorsServiceClientImpl(mockGrpcClient.Object, null);
            ReportErrorEventResponse  response = client.ReportErrorEvent(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void ReportErrorEvent()
        {
            moq::Mock <ReportErrorsService.ReportErrorsServiceClient> mockGrpcClient = new moq::Mock <ReportErrorsService.ReportErrorsServiceClient>(moq::MockBehavior.Strict);
            ReportErrorEventRequest request = new ReportErrorEventRequest
            {
                ProjectNameAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
                Event = new ReportedErrorEvent(),
            };
            ReportErrorEventResponse expectedResponse = new ReportErrorEventResponse {
            };

            mockGrpcClient.Setup(x => x.ReportErrorEvent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ReportErrorsServiceClient client   = new ReportErrorsServiceClientImpl(mockGrpcClient.Object, null);
            ReportErrorEventResponse  response = client.ReportErrorEvent(request.ProjectName, request.Event);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #3
0
        public async Task ReportErrorEventAsync2()
        {
            Mock <ReportErrorsService.ReportErrorsServiceClient> mockGrpcClient = new Mock <ReportErrorsService.ReportErrorsServiceClient>(MockBehavior.Strict);
            ReportErrorEventRequest request = new ReportErrorEventRequest
            {
                ProjectNameAsProjectName = new ProjectName("[PROJECT]"),
                Event = new ReportedErrorEvent(),
            };
            ReportErrorEventResponse expectedResponse = new ReportErrorEventResponse();

            mockGrpcClient.Setup(x => x.ReportErrorEventAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <ReportErrorEventResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            ReportErrorsServiceClient client   = new ReportErrorsServiceClientImpl(mockGrpcClient.Object, null);
            ReportErrorEventResponse  response = await client.ReportErrorEventAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task ReportErrorEventAsync()
        {
            moq::Mock <ReportErrorsService.ReportErrorsServiceClient> mockGrpcClient = new moq::Mock <ReportErrorsService.ReportErrorsServiceClient>(moq::MockBehavior.Strict);
            ReportErrorEventRequest request = new ReportErrorEventRequest
            {
                ProjectNameAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
                Event = new ReportedErrorEvent(),
            };
            ReportErrorEventResponse expectedResponse = new ReportErrorEventResponse {
            };

            mockGrpcClient.Setup(x => x.ReportErrorEventAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ReportErrorEventResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ReportErrorsServiceClient client = new ReportErrorsServiceClientImpl(mockGrpcClient.Object, null);
            ReportErrorEventResponse  responseCallSettings = await client.ReportErrorEventAsync(request.ProjectName, request.Event, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            ReportErrorEventResponse responseCancellationToken = await client.ReportErrorEventAsync(request.ProjectName, request.Event, st::CancellationToken.None);

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