Esempio n. 1
0
        public async stt::Task DeleteEventsAsync()
        {
            moq::Mock <ErrorStatsService.ErrorStatsServiceClient> mockGrpcClient = new moq::Mock <ErrorStatsService.ErrorStatsServiceClient>(moq::MockBehavior.Strict);
            DeleteEventsRequest request = new DeleteEventsRequest
            {
                ProjectNameAsProjectName = new gagr::ProjectName("[PROJECT]"),
            };
            DeleteEventsResponse expectedResponse = new DeleteEventsResponse {
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task DeleteEventsAsync2()
        {
            Mock <ErrorStatsService.ErrorStatsServiceClient> mockGrpcClient = new Mock <ErrorStatsService.ErrorStatsServiceClient>(MockBehavior.Strict);
            DeleteEventsRequest request = new DeleteEventsRequest
            {
                ProjectNameAsProjectName = new ProjectName("[PROJECT]"),
            };
            DeleteEventsResponse expectedResponse = new DeleteEventsResponse();

            mockGrpcClient.Setup(x => x.DeleteEventsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <DeleteEventsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            ErrorStatsServiceClient client   = new ErrorStatsServiceClientImpl(mockGrpcClient.Object, null);
            DeleteEventsResponse    response = await client.DeleteEventsAsync(request);

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