public async Task ErrorReportingTest()
        {
            Task <ErrorStatsServiceClient> clientTask = ErrorStatsServiceClient.CreateAsync();

            // Create a test server and make an http.
            using (TestServer server = TestServer.Create <ErrorReportingApplication>())
            {
                await server.HttpClient.GetAsync("");

                // Create a request that will filter on the TestId which is set to the service and version.
                ListGroupStatsRequest request = new ListGroupStatsRequest
                {
                    ProjectName   = new ProjectName(ProjectId).ToString(),
                    ServiceFilter = new ServiceContextFilter
                    {
                        Service = TestId,
                        Version = TestId
                    }
                };

                // Check that we have the proper results and the TestId shows up in the error.
                ErrorStatsServiceClient client = await clientTask;
                ErrorGroupStats         stats  = await client.ListGroupStatsAsync(request).FirstOrDefault();

                Assert.NotNull(stats);
                Assert.True(stats.Count > 0);
                Assert.Contains(TestId, stats.Representative.Message);
            }
        }
        /// <summary>Snippet for ListGroupStats</summary>
        public async Task ListGroupStatsAsync_RequestObject()
        {
            // Snippet: ListGroupStatsAsync(ListGroupStatsRequest, CallSettings)
            // Create client
            ErrorStatsServiceClient errorStatsServiceClient = await ErrorStatsServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListGroupStatsRequest request = new ListGroupStatsRequest
            {
                ProjectNameAsProjectName = new ProjectName("[PROJECT]"),
                GroupId            = { "", },
                ServiceFilter      = new ServiceContextFilter(),
                TimeRange          = new QueryTimeRange(),
                TimedCountDuration = new Duration(),
                Alignment          = TimedCountAlignment.ErrorCountAlignmentUnspecified,
                AlignmentTime      = new Timestamp(),
                Order = ErrorGroupOrder.GroupOrderUnspecified,
            };
            // Make the request
            PagedAsyncEnumerable <ListGroupStatsResponse, ErrorGroupStats> response = errorStatsServiceClient.ListGroupStatsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((ErrorGroupStats item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListGroupStatsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (ErrorGroupStats item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <ErrorGroupStats> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (ErrorGroupStats item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
        /// <summary>Snippet for DeleteEventsAsync</summary>
        public async Task DeleteEventsAsync()
        {
            // Snippet: DeleteEventsAsync(ProjectName,CallSettings)
            // Additional: DeleteEventsAsync(ProjectName,CancellationToken)
            // Create client
            ErrorStatsServiceClient errorStatsServiceClient = await ErrorStatsServiceClient.CreateAsync();

            // Initialize request argument(s)
            ProjectName projectName = new ProjectName("[PROJECT]");
            // Make the request
            DeleteEventsResponse response = await errorStatsServiceClient.DeleteEventsAsync(projectName);

            // End snippet
        }
        public async Task DeleteEventsAsync_RequestObject()
        {
            // Snippet: DeleteEventsAsync(DeleteEventsRequest,CallSettings)
            // Create client
            ErrorStatsServiceClient errorStatsServiceClient = await ErrorStatsServiceClient.CreateAsync();

            // Initialize request argument(s)
            DeleteEventsRequest request = new DeleteEventsRequest
            {
                ProjectNameAsProjectName = new ProjectName("[PROJECT]"),
            };
            // Make the request
            DeleteEventsResponse response = await errorStatsServiceClient.DeleteEventsAsync(request);

            // End snippet
        }
        /// <summary>Snippet for ListEvents</summary>
        public async Task ListEventsAsync_ResourceNames()
        {
            // Snippet: ListEventsAsync(ProjectName, string, string, int?, CallSettings)
            // Create client
            ErrorStatsServiceClient errorStatsServiceClient = await ErrorStatsServiceClient.CreateAsync();

            // Initialize request argument(s)
            ProjectName projectName = new ProjectName("[PROJECT]");
            string      groupId     = "";
            // Make the request
            PagedAsyncEnumerable <ListEventsResponse, ErrorEvent> response = errorStatsServiceClient.ListEventsAsync(projectName, groupId);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((ErrorEvent item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListEventsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (ErrorEvent item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <ErrorEvent> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (ErrorEvent item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }