<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Core.DomainModel;
using Core.DomainModel.Organization;
using Tests.Integration.Presentation.Web.Tools;
using Tests.Toolkit.Patterns;
using Xunit;

namespace Tests.Integration.Presentation.Web.Authorization
{
    public class GetOrganizationsTests : WithAutoFixture
    {
        [Theory]
        [InlineData(true)]
        [InlineData(false)]
        public async Task Get_Organizations_Returns_List_Sorted_By_Name(bool orderByAsc)
        {
            var orderBy = "Name";
            var organization1 = await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, "OrgTest" + Guid.NewGuid(), "13370000", OrganizationTypeKeys.Kommune, AccessModifier.Public);
            var organization2 = await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, "TestOrg1" + Guid.NewGuid(), "13370000", OrganizationTypeKeys.Kommune, AccessModifier.Public);
            var organization3 = await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, "TestOrg2" + Guid.NewGuid(), "13370000", OrganizationTypeKeys.Kommune, AccessModifier.Public);

            var response = await OrganizationHelper.GetOrganizationsResponseAsync(orderBy, orderByAsc);
            Assert.True(response.IsSuccessStatusCode);

            var result = await response.ReadResponseBodyAsKitosApiResponseAsync<List<Organization>>();
            var indexOfOrg1 = result.IndexOf(result.FirstOrDefault(prp => prp.Id == organization1.Id));
            var indexOfOrg2 = result.IndexOf(result.FirstOrDefault(prp => prp.Id == organization2.Id));
            var indexOfOrg3 = result.IndexOf(result.FirstOrDefault(prp => prp.Id == organization3.Id));

            if (orderByAsc)
            {
                Assert.True(indexOfOrg1 < indexOfOrg2);
                Assert.True(indexOfOrg2 < indexOfOrg3);
                return;
            }

            Assert.True(indexOfOrg1 > indexOfOrg2);
            Assert.True(indexOfOrg2 > indexOfOrg3);
        }

        [Fact]
        public async Task Get_Organizations_Does_Not_Allow_For_Property_Other_Than_Name()
        {
            var incorrectOrderBy = "IncorrectPropertyName";

            var response = await OrganizationHelper.GetOrganizationsResponseAsync(incorrectOrderBy);

            Assert.True(!response.IsSuccessStatusCode);
            Assert.True(response.StatusCode == HttpStatusCode.BadRequest);
        }

        [Theory]
        [InlineData("")]
        [InlineData(null)]
        public async Task Get_Organizations_Returns_List_When_Name_Parameter_Is_Empty(string orderBy)
        {
            await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, "OrgTest" + Guid.NewGuid(), "13370000", OrganizationTypeKeys.Kommune, AccessModifier.Public);
            await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, "TestOrg1" + Guid.NewGuid(), "13370000", OrganizationTypeKeys.Kommune, AccessModifier.Public);

            var response = await OrganizationHelper.GetOrganizationsResponseAsync(orderBy);
            Assert.True(response.IsSuccessStatusCode);

            var result = await response.ReadResponseBodyAsKitosApiResponseAsync<List<Organization>>();

            Assert.True(result.Count >= 2);
        }
    }
}
<commit_msg>Test change<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Core.DomainModel;
using Core.DomainModel.Organization;
using Tests.Integration.Presentation.Web.Tools;
using Tests.Toolkit.Patterns;
using Xunit;

namespace Tests.Integration.Presentation.Web.Authorization
{
    public class GetOrganizationsTests : WithAutoFixture
    {
        [Theory]
        [InlineData(true)]
        [InlineData(false)]
        public async Task Get_Organizations_Returns_List_Sorted_By_Name(bool orderByAsc)
        {
            var orderBy = "Name";
            var organization1 = await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, "OrgTest" + Guid.NewGuid(), "13370000", OrganizationTypeKeys.Kommune, AccessModifier.Public);
            var organization2 = await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, "TestOrg1" + Guid.NewGuid(), "13370000", OrganizationTypeKeys.Kommune, AccessModifier.Public);
            var organization3 = await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, "TestOrg2" + Guid.NewGuid(), "13370000", OrganizationTypeKeys.Kommune, AccessModifier.Public);

            var response = await OrganizationHelper.GetOrganizationsResponseAsync(orderBy, orderByAsc);
            Assert.True(response.IsSuccessStatusCode);

            var result = await response.ReadResponseBodyAsKitosApiResponseAsync<List<Organization>>();
            var indexOfOrg1 = result.IndexOf(result.FirstOrDefault(prp => prp.Id == organization1.Id));
            var indexOfOrg2 = result.IndexOf(result.FirstOrDefault(prp => prp.Id == organization2.Id));
            var indexOfOrg3 = result.IndexOf(result.FirstOrDefault(prp => prp.Id == organization3.Id));

            if (orderByAsc)
            {
                Assert.True(indexOfOrg1 < indexOfOrg2);
                Assert.True(indexOfOrg2 < indexOfOrg3);
                return;
            }

            Assert.True(indexOfOrg1 > indexOfOrg2);
            Assert.True(indexOfOrg2 > indexOfOrg3);
        }

        [Fact]
        public async Task Get_Organizations_Does_Not_Allow_For_Property_Other_Than_Name()
        {
            var incorrectOrderBy = "IncorrectPropertyName";

            var response = await OrganizationHelper.GetOrganizationsResponseAsync(incorrectOrderBy);
            
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }

        [Theory]
        [InlineData("")]
        [InlineData(null)]
        public async Task Get_Organizations_Returns_List_When_Name_Parameter_Is_Empty(string orderBy)
        {
            await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, "OrgTest" + Guid.NewGuid(), "13370000", OrganizationTypeKeys.Kommune, AccessModifier.Public);
            await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, "TestOrg1" + Guid.NewGuid(), "13370000", OrganizationTypeKeys.Kommune, AccessModifier.Public);

            var response = await OrganizationHelper.GetOrganizationsResponseAsync(orderBy);
            Assert.True(response.IsSuccessStatusCode);

            var result = await response.ReadResponseBodyAsKitosApiResponseAsync<List<Organization>>();

            Assert.True(result.Count >= 2);
        }
    }
}

{'fraction_non_alphanumeric': 0.08988276161528441, 'fraction_numerical': 0.017658127080619482, 'mean_word_length': 3.492847854356307, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, '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': '3317866', 'n_tokens_mistral': 1909, 'n_tokens_neox': 1828, 'n_words': 300}