<commit_before>// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
using System.Xml.Linq;
using FormatterWebSite;
using Xunit;

namespace Microsoft.AspNetCore.Mvc.FunctionalTests
{
    public class AsyncEnumerableTestBase : IClassFixture<MvcTestFixture<StartupWithJsonFormatter>>
    {
        public AsyncEnumerableTestBase(MvcTestFixture<StartupWithJsonFormatter> fixture)
        {
            Client = fixture.CreateDefaultClient();
        }

        public HttpClient Client { get; }

        [Fact]
        public Task AsyncEnumerableReturnedWorks() => AsyncEnumerableWorks();

        [Fact]
        public Task AsyncEnumerableWrappedInTask() => AsyncEnumerableWorks();

        private async Task AsyncEnumerableWorks()
        {
            // Act
            var response = await Client.GetAsync("asyncenumerable/getallprojects");

            // Assert
            await response.AssertStatusCodeAsync(HttpStatusCode.OK);

            var content = await response.Content.ReadAsStringAsync();

            // Some sanity tests to verify things serialized correctly.
            var projects = JsonSerializer.Deserialize<List<Project>>(content, TestJsonSerializerOptionsProvider.Options);
            Assert.Equal(10, projects.Count);
            Assert.Equal("Project0", projects[0].Name);
            Assert.Equal("Project9", projects[9].Name);
        }

        [Fact]
        public async Task AsyncEnumerableExceptionsAreThrown()
        {
            // Act
            var response = await Client.GetAsync("asyncenumerable/GetAllProjectsWithError");

            // Assert
            await response.AssertStatusCodeAsync(HttpStatusCode.InternalServerError);
<commit_msg>Fix AsyncEnumerableTest to actually test GetAllProjectsAsTask endpoint (#35514)<commit_after>// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
using System.Xml.Linq;
using FormatterWebSite;
using Xunit;

namespace Microsoft.AspNetCore.Mvc.FunctionalTests
{
    public class AsyncEnumerableTestBase : IClassFixture<MvcTestFixture<StartupWithJsonFormatter>>
    {
        public AsyncEnumerableTestBase(MvcTestFixture<StartupWithJsonFormatter> fixture)
        {
            Client = fixture.CreateDefaultClient();
        }

        public HttpClient Client { get; }

        [Fact]
        public Task AsyncEnumerableReturnedWorks() => AsyncEnumerableWorks("getallprojects");

        [Fact]
        public Task AsyncEnumerableWrappedInTask() => AsyncEnumerableWorks("getallprojectsastask");

        private async Task AsyncEnumerableWorks(string action)
        {
            // Act
            var response = await Client.GetAsync($"asyncenumerable/{action}");

            // Assert
            await response.AssertStatusCodeAsync(HttpStatusCode.OK);

            var content = await response.Content.ReadAsStringAsync();

            // Some sanity tests to verify things serialized correctly.
            var projects = JsonSerializer.Deserialize<List<Project>>(content, TestJsonSerializerOptionsProvider.Options);
            Assert.Equal(10, projects.Count);
            Assert.Equal("Project0", projects[0].Name);
            Assert.Equal("Project9", projects[9].Name);
        }

        [Fact]
        public async Task AsyncEnumerableExceptionsAreThrown()
        {
            // Act
            var response = await Client.GetAsync("asyncenumerable/GetAllProjectsWithError");

            // Assert
            await response.AssertStatusCodeAsync(HttpStatusCode.InternalServerError);

{'fraction_non_alphanumeric': 0.08475426278836509, 'fraction_numerical': 0.004262788365095286, 'mean_word_length': 2.9378084896347483, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '826060', 'n_tokens_mistral': 977, 'n_tokens_neox': 967, 'n_words': 238}