diff --git a/.github/workflows/designer-dotnet-test.yaml b/.github/workflows/designer-dotnet-test.yaml index a74051276cc..73ee96deeb4 100644 --- a/.github/workflows/designer-dotnet-test.yaml +++ b/.github/workflows/designer-dotnet-test.yaml @@ -17,7 +17,7 @@ jobs: analyze: strategy: matrix: - os: [ubuntu-latest] #windows-latest and macos-latest excluded temporarily + os: [ubuntu-latest,windows-latest,macos-latest] #windows-latest and macos-latest excluded temporarily name: Run dotnet build and test runs-on: ${{ matrix.os}} env: @@ -33,7 +33,7 @@ jobs: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Build run: | - dotnet build backend/Designer.sln -v n -nodereuse:false + dotnet build backend/Designer.sln -v m - name: Test run: | - dotnet test backend/Designer.sln --filter Category!=GiteaIntegrationTest -v n --no-build + dotnet test backend/Designer.sln --filter FullyQualifiedName~AppDevelopmentController --no-build; dotnet test backend/Designer.sln --filter FullyQualifiedName~PreviewController --no-build; dotnet test backend/Designer.sln --filter "(Category!=GiteaIntegrationTest)&(FullyQualifiedName!~AppDevelopmentController)&(FullyQualifiedName!~PreviewController)" -v m --no-build diff --git a/backend/src/Designer/Program.cs b/backend/src/Designer/Program.cs index 353d468347f..00eb3c4d778 100644 --- a/backend/src/Designer/Program.cs +++ b/backend/src/Designer/Program.cs @@ -359,3 +359,5 @@ static string GetXmlCommentsPathForControllers() return xmlPath; } + +public partial class Program { } diff --git a/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs b/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs index d7117d1d69d..490adac1a71 100644 --- a/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs +++ b/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs @@ -37,7 +37,6 @@ public interface IProcessModelingService /// Gets the process definition file stream for a given app. /// /// An . - /// A that observes if operation is cancelled. /// A of a process definition file. Stream GetProcessDefinitionStream(AltinnRepoEditingContext altinnRepoEditingContext); } diff --git a/backend/tests/Designer.Tests/Controllers/ApiTests/ApiTestsBase.cs b/backend/tests/Designer.Tests/Controllers/ApiTests/ApiTestsBase.cs index 9e94e66f1ce..ee575351fb9 100644 --- a/backend/tests/Designer.Tests/Controllers/ApiTests/ApiTestsBase.cs +++ b/backend/tests/Designer.Tests/Controllers/ApiTests/ApiTestsBase.cs @@ -2,17 +2,12 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing.Handlers; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; using SharedResources.Tests; -using Xunit; using static Designer.Tests.Utils.TestSetupUtils; namespace Designer.Tests.Controllers.ApiTests; @@ -20,18 +15,22 @@ namespace Designer.Tests.Controllers.ApiTests; /// /// Base class for testing controller endpoints. /// -/// Provided controller type. /// Controller test class type. Used for generating fluent tests. [ExcludeFromCodeCoverage] -public abstract class ApiTestsBase : FluentTestsBase, - IClassFixture> - where TController : ControllerBase - where TControllerTest : class +public abstract class ApiTestsBase : FluentTestsBase, IDisposable where TControllerTest : class { + private HttpClient _httpClient; + /// /// HttpClient that should call endpoints of a provided controller. /// - protected Lazy HttpClient { get; } + protected HttpClient HttpClient + { + get + { + return _httpClient ??= GetTestClient(); + } + } /// /// When overridden tests services will be configured. @@ -50,12 +49,11 @@ public abstract class ApiTestsBase : FluentTestsBa protected virtual string TestRepositoriesLocation => Path.Combine(UnitTestsFolder, "..", "..", "..", "_TestData", "Repositories"); - protected readonly WebApplicationFactory Factory; + protected readonly WebApplicationFactory Factory; - protected ApiTestsBase(WebApplicationFactory factory) + protected ApiTestsBase(WebApplicationFactory factory) { Factory = factory; - HttpClient = new Lazy(GetTestClient); SetupDirtyHackIfLinux(); } @@ -67,15 +65,11 @@ protected ApiTestsBase(WebApplicationFactory factory) protected virtual HttpClient GetTestClient() { string configPath = GetConfigPath(); - - var client = Factory.WithWebHostBuilder(builder => + return Factory.WithWebHostBuilder(builder => { - builder.UseTestServer(); builder.ConfigureAppConfiguration((_, conf) => { conf.AddJsonFile(configPath); }); - builder.ConfigureTestServices(ConfigureTestServices); }).CreateDefaultClient(new ApiTestsAuthAndCookieDelegatingHandler(), new CookieContainerHandler()); - return client; } /// @@ -87,4 +81,11 @@ protected virtual string GetConfigPath() string projectDir = Directory.GetCurrentDirectory(); return Path.Combine(projectDir, "appsettings.json"); } + public void Dispose() + { + Dispose(true); + } + protected virtual void Dispose(bool disposing) + { + } } diff --git a/backend/tests/Designer.Tests/Controllers/ApiTests/DisagnerEndpointsTestsBase.cs b/backend/tests/Designer.Tests/Controllers/ApiTests/DisagnerEndpointsTestsBase.cs index 6bcb8462e50..2d0923a21a3 100644 --- a/backend/tests/Designer.Tests/Controllers/ApiTests/DisagnerEndpointsTestsBase.cs +++ b/backend/tests/Designer.Tests/Controllers/ApiTests/DisagnerEndpointsTestsBase.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Text.Encodings.Web; using System.Text.Json; using System.Text.Json.Serialization; @@ -17,10 +18,8 @@ namespace Designer.Tests.Controllers.ApiTests /// More adjusted version of the ApiTestsBase class that is used for testing controllers that contains org and repo in the path. /// Provides functionality for copying a repository from the test repositories location to a temporary location for testing which is disposed after execution of the test. /// - /// Controller type. /// Tests class type. - public abstract class DisagnerEndpointsTestsBase : ApiTestsBase, IDisposable - where TController : ControllerBase + public abstract class DisagnerEndpointsTestsBase : ApiTestsBase where TControllerTest : class { /// @@ -49,7 +48,7 @@ protected override void ConfigureTestServices(IServiceCollection services) Converters = { new JsonStringEnumConverter() } }; - public DisagnerEndpointsTestsBase(WebApplicationFactory factory) : base(factory) + public DisagnerEndpointsTestsBase(WebApplicationFactory factory) : base(factory) { } @@ -90,19 +89,20 @@ protected async Task CopyRemoteRepositoryForTest(string org, string repo, string RemoteTestRepoPath = await TestDataHelper.CopyRemoteRepositoryForTest(org, repo, targetRepository); } - public void Dispose() + protected override void Dispose(bool disposing) { - if (!string.IsNullOrWhiteSpace(TestRepoPath)) + base.Dispose(disposing); + if (!disposing) { - TestDataHelper.DeleteDirectory(TestRepoPath); + return; } - if (!string.IsNullOrWhiteSpace(RemoteTestRepoPath)) + if (!string.IsNullOrWhiteSpace(TestRepoPath)) { - TestDataHelper.DeleteDirectory(RemoteTestRepoPath); + Directory.Delete(TestRepoPath, true); } - if (HttpClient.IsValueCreated) + if (!string.IsNullOrWhiteSpace(RemoteTestRepoPath)) { - HttpClient.Value.Dispose(); + Directory.Delete(RemoteTestRepoPath, true); } } } diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/DeleteFormLayoutTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/DeleteFormLayoutTests.cs index 3ae582ffeea..8f782c082f0 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/DeleteFormLayoutTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/DeleteFormLayoutTests.cs @@ -11,10 +11,10 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class DeleteFormLayoutTests : DisagnerEndpointsTestsBase + public class DeleteFormLayoutTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development"; - public DeleteFormLayoutTests(WebApplicationFactory factory) : base(factory) + public DeleteFormLayoutTests(WebApplicationFactory factory) : base(factory) { } @@ -30,7 +30,7 @@ public async Task DeleteFormLayout_ShouldDeleteLayoutFile_AndReturnOk(string org using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string relativePath = string.IsNullOrEmpty(layoutSetName) @@ -52,7 +52,7 @@ public async Task DeleteFormLayout_NonExistingFile_Should_AndReturnNotFound(stri using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.NotFound); } } diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetFormLayoutsTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetFormLayoutsTests.cs index 9a26d9f74f1..7b997c99a73 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetFormLayoutsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetFormLayoutsTests.cs @@ -16,10 +16,10 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class GetFormLayoutsTests : DisagnerEndpointsTestsBase + public class GetFormLayoutsTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development"; - public GetFormLayoutsTests(WebApplicationFactory factory) : base(factory) + public GetFormLayoutsTests(WebApplicationFactory factory) : base(factory) { } @@ -35,7 +35,7 @@ public async Task GetAppDevelopment_ShouldReturnLayouts(string org, string app, string url = $"{VersionPrefix(org, targetRepository)}/form-layouts?layoutSetName={layoutSetName}"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetLayoutSettingsTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetLayoutSettingsTests.cs index 73ba75ffc1b..7987a91af00 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetLayoutSettingsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetLayoutSettingsTests.cs @@ -11,10 +11,10 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class GetLayoutSettingsTests : DisagnerEndpointsTestsBase + public class GetLayoutSettingsTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development"; - public GetLayoutSettingsTests(WebApplicationFactory factory) : base(factory) + public GetLayoutSettingsTests(WebApplicationFactory factory) : base(factory) { } @@ -35,7 +35,7 @@ public async Task GetLayoutSettings_ShouldReturnLayouts(string org, string app, string url = $"{VersionPrefix(org, targetRepository)}/layout-settings?layoutSetName={layoutSetName}"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await response.Content.ReadAsStringAsync(); @@ -50,7 +50,7 @@ public async Task GetLayoutSettings_IfNotExists_Should_AndReturnNotFound(string string url = $"{VersionPrefix(org, app)}/layout-settings?layoutSetName={layoutSetName}"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.NotFound); } diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetOptionListIdsTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetOptionListIdsTests.cs index 4faef2e59bd..fa89b1e0890 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetOptionListIdsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetOptionListIdsTests.cs @@ -11,10 +11,10 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class GetOptionListIdsTests : DisagnerEndpointsTestsBase + public class GetOptionListIdsTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development"; - public GetOptionListIdsTests(WebApplicationFactory factory) : base(factory) + public GetOptionListIdsTests(WebApplicationFactory factory) : base(factory) { } @@ -34,7 +34,7 @@ public async Task GetOptionsListIds_ShouldReturnOk(string org, string app, strin string url = $"{VersionPrefix(org, targetRepository)}/option-list-ids"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await response.Content.ReadAsStringAsync(); @@ -53,7 +53,7 @@ public async Task GetOptionsListIds_WhenNotExists_ReturnsNotFound(string org, st string url = $"{VersionPrefix(org, app)}/option-list-ids"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.NoContent); } diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetRuleConfigTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetRuleConfigTests.cs index 7b4925f715d..e5894e8b1c5 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetRuleConfigTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetRuleConfigTests.cs @@ -11,10 +11,10 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class GetRuleConfigTests : DisagnerEndpointsTestsBase + public class GetRuleConfigTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development"; - public GetRuleConfigTests(WebApplicationFactory factory) : base(factory) + public GetRuleConfigTests(WebApplicationFactory factory) : base(factory) { } @@ -32,7 +32,7 @@ public async Task GetRuleConfig_ShouldReturnOK(string org, string app, string de string url = $"{VersionPrefix(org, targetRepository)}/rule-config?layoutSetName={layoutSetName}"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await response.Content.ReadAsStringAsync(); @@ -46,7 +46,7 @@ public async Task GetRuleConfig_WhenNotExists_ReturnsNotFound(string org, string string url = $"{VersionPrefix(org, app)}/rule-config?layoutSetName={layoutSetName}"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.NoContent); } @@ -64,7 +64,7 @@ public async Task GetRuleConfig_WhenFileMissesDataOnRoot_ReturnsFixedFile(string string url = $"{VersionPrefix(org, targetRepository)}/rule-config?layoutSetName={layoutSetName}"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetRuleHandlerTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetRuleHandlerTests.cs index e182b5a16db..1a926588629 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetRuleHandlerTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetRuleHandlerTests.cs @@ -11,10 +11,10 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class GetRuleHandlerTests : DisagnerEndpointsTestsBase + public class GetRuleHandlerTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development"; - public GetRuleHandlerTests(WebApplicationFactory factory) : base(factory) + public GetRuleHandlerTests(WebApplicationFactory factory) : base(factory) { } @@ -35,7 +35,7 @@ public async Task GetRuleHandler_ShouldReturnJsContent(string org, string app, s string url = $"{VersionPrefix(org, targetRepository)}/rule-handler?layoutSetName={layoutSetName}"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await response.Content.ReadAsStringAsync(); @@ -50,7 +50,7 @@ public async Task GetRuleHandler_IfNotExists_Should_AndReturnNotFound(string org string url = $"{VersionPrefix(org, app)}/rule-handler?layoutSetName={layoutSetName}"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.NotFound); string content = await response.Content.ReadAsStringAsync(); content.Should().Be("Could not find rule handler in app."); diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetVersionOfTheAppLibTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetVersionOfTheAppLibTests.cs index 55143b3b2ef..e2c69d829a7 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetVersionOfTheAppLibTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetVersionOfTheAppLibTests.cs @@ -12,10 +12,10 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class GetVersionOfTheAppLibTests : DisagnerEndpointsTestsBase + public class GetVersionOfTheAppLibTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development/app-lib-version"; - public GetVersionOfTheAppLibTests(WebApplicationFactory factory) : base(factory) + public GetVersionOfTheAppLibTests(WebApplicationFactory factory) : base(factory) { } @@ -30,7 +30,7 @@ public async Task GetAppLibVersion_GivenCsProjFile_ShouldReturnOK(string org, st string url = VersionPrefix(org, targetRepository); - using var response = await HttpClient.Value.GetAsync(url); + using var response = await HttpClient.GetAsync(url); response.StatusCode.Should().Be(HttpStatusCode.OK); var responseVersion = await response.Content.ReadAsAsync(); @@ -47,7 +47,7 @@ public async Task GetAppLibVersion_GivenCsprojFileWithoutAppLib_ShouldReturn404( await AddCsProjToRepo("App/App.csproj", csprojTemplate); string url = VersionPrefix(org, targetRepository); - using var response = await HttpClient.Value.GetAsync(url); + using var response = await HttpClient.GetAsync(url); response.StatusCode.Should().Be(HttpStatusCode.NotFound); } @@ -57,7 +57,7 @@ public async Task GetAppLibVersion_NotGivenCsprojFile_ShouldReturn404(string org { string url = VersionPrefix(org, app); - using var response = await HttpClient.Value.GetAsync(url); + using var response = await HttpClient.GetAsync(url); response.StatusCode.Should().Be(HttpStatusCode.NotFound); } diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveFormLayoutTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveFormLayoutTests.cs index 5481f495723..15c3b4566b8 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveFormLayoutTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveFormLayoutTests.cs @@ -12,10 +12,10 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class SaveFormLayoutTestsBase : DisagnerEndpointsTestsBase + public class SaveFormLayoutTestsBase : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development"; - public SaveFormLayoutTestsBase(WebApplicationFactory factory) : base(factory) + public SaveFormLayoutTestsBase(WebApplicationFactory factory) : base(factory) { } @@ -48,7 +48,7 @@ public async Task SaveFormLayout_ReturnsOk(string org, string app, string develo Content = new StringContent(layout, Encoding.UTF8, MediaTypeNames.Application.Json) }; - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string relativePath = string.IsNullOrEmpty(layoutSetName) diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveLayoutSettingsTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveLayoutSettingsTests.cs index 64fb9f767a3..fdc10ce82ec 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveLayoutSettingsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveLayoutSettingsTests.cs @@ -12,11 +12,11 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class SaveLayoutSettingsTests : DisagnerEndpointsTestsBase + public class SaveLayoutSettingsTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development"; - public SaveLayoutSettingsTests(WebApplicationFactory factory) : base(factory) + public SaveLayoutSettingsTests(WebApplicationFactory factory) : base(factory) { } @@ -43,7 +43,7 @@ public async Task SaveLayoutSettings_ReturnsOk(string org, string app, string de Content = new StringContent(layoutSettings, Encoding.UTF8, MediaTypeNames.Application.Json) }; - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string relativePath = string.IsNullOrEmpty(layoutSetName) diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveRuleConfigTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveRuleConfigTests.cs index 2917bc7c1d4..1872a94031e 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveRuleConfigTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveRuleConfigTests.cs @@ -12,11 +12,11 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class SaveRuleConfigTests : DisagnerEndpointsTestsBase + public class SaveRuleConfigTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development"; - public SaveRuleConfigTests(WebApplicationFactory factory) : base(factory) + public SaveRuleConfigTests(WebApplicationFactory factory) : base(factory) { } @@ -38,7 +38,7 @@ public async Task SaveRuleConfiguration_ShouldCreateRuleConfigurationFile_AndRet Content = new StringContent(content, Encoding.UTF8, MediaTypeNames.Application.Json) }; - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string relativePath = string.IsNullOrEmpty(layoutSetName) diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveRuleHandlerTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveRuleHandlerTests.cs index 2a34bb4be83..8d950cf5717 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveRuleHandlerTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/SaveRuleHandlerTests.cs @@ -15,11 +15,11 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class SaveRuleHandlerTests : DisagnerEndpointsTestsBase + public class SaveRuleHandlerTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development"; - public SaveRuleHandlerTests(WebApplicationFactory factory) : base(factory) + public SaveRuleHandlerTests(WebApplicationFactory factory) : base(factory) { } @@ -51,7 +51,7 @@ public async Task SaveRuleHandler_ShouldCreateRuleHandlerFile_AndReturnNoContent Content = new StringContent(content, Encoding.UTF8) }; - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.NoContent); string relativePath = string.IsNullOrEmpty(layoutSetName) diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/UpdateFormLayoutNameTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/UpdateFormLayoutNameTests.cs index 825ddb6c9e4..378d5ef60e7 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/UpdateFormLayoutNameTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/UpdateFormLayoutNameTests.cs @@ -12,10 +12,10 @@ namespace Designer.Tests.Controllers.AppDevelopmentController { - public class UpdateFormLayoutNameTests : DisagnerEndpointsTestsBase + public class UpdateFormLayoutNameTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/app-development"; - public UpdateFormLayoutNameTests(WebApplicationFactory factory) : base(factory) + public UpdateFormLayoutNameTests(WebApplicationFactory factory) : base(factory) { } @@ -36,7 +36,7 @@ public async Task UpdateFormLayoutName_Change_FileName_And_ReturnsOk(string org, Content = new StringContent($"\"{newLayoutName}\"", Encoding.UTF8, MediaTypeNames.Application.Json) }; - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string relativeOldLayoutPath = string.IsNullOrEmpty(layoutSetName) @@ -65,7 +65,7 @@ public async Task UpdateFormLayoutName_NonExistingName_ShouldReturnNotFound(stri Content = new StringContent($"\"{newLayoutName}\"", Encoding.UTF8, MediaTypeNames.Application.Json) }; - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.NotFound); } diff --git a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/AddMetadataForAttachmentTests.cs b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/AddMetadataForAttachmentTests.cs index 241951747b8..68df3fabdf3 100644 --- a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/AddMetadataForAttachmentTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/AddMetadataForAttachmentTests.cs @@ -16,10 +16,10 @@ namespace Designer.Tests.Controllers.ApplicationMetadataController { - public class AddMetadataForAttachmentTests : DisagnerEndpointsTestsBase + public class AddMetadataForAttachmentTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/metadata"; - public AddMetadataForAttachmentTests(WebApplicationFactory factory) : base(factory) + public AddMetadataForAttachmentTests(WebApplicationFactory factory) : base(factory) { } @@ -34,7 +34,7 @@ public async Task AddMetadataForAttachment_WhenExists_ShouldReturnConflict(strin // payload using var payloadContent = new StringContent(JsonSerializer.Serialize(payload, JsonSerializerOptions), Encoding.UTF8, MediaTypeNames.Application.Json); - using var response = await HttpClient.Value.PostAsync(url, payloadContent); + using var response = await HttpClient.PostAsync(url, payloadContent); response.StatusCode.Should().Be(HttpStatusCode.OK); diff --git a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/CreateApplicationMetadataTests.cs b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/CreateApplicationMetadataTests.cs index b5e29e1123a..9daae5fa108 100644 --- a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/CreateApplicationMetadataTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/CreateApplicationMetadataTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.ApplicationMetadataController { - public class CreateApplicationMetadataTests : DisagnerEndpointsTestsBase + public class CreateApplicationMetadataTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/metadata"; - public CreateApplicationMetadataTests(WebApplicationFactory factory) : base(factory) + public CreateApplicationMetadataTests(WebApplicationFactory factory) : base(factory) { } @@ -27,7 +27,7 @@ public async Task CreateApplicationMetadata_WhenExists_ShouldReturnConflict(stri string url = VersionPrefix(org, targetRepository); using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url); - using var response = await HttpClient.Value.SendAsync(request); + using var response = await HttpClient.SendAsync(request); response.StatusCode.Should().Be(HttpStatusCode.Conflict); } @@ -44,7 +44,7 @@ public async Task CreateApplicationMetadata_ShouldReturnOK(string org, string ap string url = VersionPrefix(org, targetRepository); using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url); - using var response = await HttpClient.Value.SendAsync(request); + using var response = await HttpClient.SendAsync(request); response.StatusCode.Should().Be(HttpStatusCode.Created); } diff --git a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/DeleteMetadataForAttachmentTests.cs b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/DeleteMetadataForAttachmentTests.cs index cd30c726493..b6adf009a01 100644 --- a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/DeleteMetadataForAttachmentTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/DeleteMetadataForAttachmentTests.cs @@ -13,10 +13,10 @@ namespace Designer.Tests.Controllers.ApplicationMetadataController { - public class DeleteMetadataForAttachmentTests : DisagnerEndpointsTestsBase + public class DeleteMetadataForAttachmentTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/metadata"; - public DeleteMetadataForAttachmentTests(WebApplicationFactory factory) : base(factory) + public DeleteMetadataForAttachmentTests(WebApplicationFactory factory) : base(factory) { } @@ -34,7 +34,7 @@ public async Task DeleteMetadataForAttachment_WhenExists_ShouldReturnOk(string o using var requestMessage = new HttpRequestMessage(HttpMethod.Delete, url); requestMessage.Content = new StringContent($"\"{attacmentIdToDelete}\"", Encoding.UTF8, MediaTypeNames.Application.Json); - var response = await HttpClient.Value.SendAsync(requestMessage); + var response = await HttpClient.SendAsync(requestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string currentMetadata = TestDataHelper.GetFileFromRepo(org, targetRepository, developer, "App/config/applicationmetadata.json"); diff --git a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/GetApplicationMetadataTests.cs b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/GetApplicationMetadataTests.cs index ebde04b8611..956ab916335 100644 --- a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/GetApplicationMetadataTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/GetApplicationMetadataTests.cs @@ -12,10 +12,10 @@ namespace Designer.Tests.Controllers.ApplicationMetadataController { - public class GetApplicationMetadataTests : DisagnerEndpointsTestsBase + public class GetApplicationMetadataTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/metadata"; - public GetApplicationMetadataTests(WebApplicationFactory factory) : base(factory) + public GetApplicationMetadataTests(WebApplicationFactory factory) : base(factory) { } @@ -32,7 +32,7 @@ public async Task GetApplicationMetadata_ShouldReturnOK(string org, string app, await File.WriteAllTextAsync(filePath, metadataFile); string url = VersionPrefix(org, targetRepository); - var response = await HttpClient.Value.GetAsync(url); + var response = await HttpClient.GetAsync(url); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateApplicationMetadataTests.cs b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateApplicationMetadataTests.cs index e92f19c9b66..a5d9c7f8479 100644 --- a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateApplicationMetadataTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateApplicationMetadataTests.cs @@ -14,10 +14,10 @@ namespace Designer.Tests.Controllers.ApplicationMetadataController { - public class UpdateApplicationMetadataTests : DisagnerEndpointsTestsBase + public class UpdateApplicationMetadataTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/metadata"; - public UpdateApplicationMetadataTests(WebApplicationFactory factory) : base(factory) + public UpdateApplicationMetadataTests(WebApplicationFactory factory) : base(factory) { } @@ -33,7 +33,7 @@ public async Task UpdateApplicationMetadata_WhenExists_ShouldReturnConflict(stri string url = VersionPrefix(org, targetRepository); - var response = await HttpClient.Value.PutAsync(url, new StringContent(metadata, Encoding.UTF8, MediaTypeNames.Application.Json)); + using var response = await HttpClient.PutAsync(url, new StringContent(metadata, Encoding.UTF8, MediaTypeNames.Application.Json)); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateMetadataForAttachmentTests.cs b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateMetadataForAttachmentTests.cs index af5e1d6bb5c..d9bf973552e 100644 --- a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateMetadataForAttachmentTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateMetadataForAttachmentTests.cs @@ -17,10 +17,10 @@ namespace Designer.Tests.Controllers.ApplicationMetadataController { - public class UpdateMetadataForAttachmentTests : DisagnerEndpointsTestsBase + public class UpdateMetadataForAttachmentTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/metadata"; - public UpdateMetadataForAttachmentTests(WebApplicationFactory factory) : base(factory) + public UpdateMetadataForAttachmentTests(WebApplicationFactory factory) : base(factory) { } @@ -41,7 +41,7 @@ public async Task UpdateMetadataForAttachment_WhenExists_ShouldReturnConflict(st // payload using var payloadContent = new StringContent(payload, Encoding.UTF8, MediaTypeNames.Application.Json); - using var response = await HttpClient.Value.PutAsync(url, payloadContent); + using var response = await HttpClient.PutAsync(url, payloadContent); response.StatusCode.Should().Be(HttpStatusCode.OK); diff --git a/backend/tests/Designer.Tests/Controllers/ConfigController/GetServiceConfigTests.cs b/backend/tests/Designer.Tests/Controllers/ConfigController/GetServiceConfigTests.cs index 5d13836399a..20e1aa0cfff 100644 --- a/backend/tests/Designer.Tests/Controllers/ConfigController/GetServiceConfigTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ConfigController/GetServiceConfigTests.cs @@ -8,10 +8,10 @@ namespace Designer.Tests.Controllers.ConfigController { - public class GetServiceConfigTests : DisagnerEndpointsTestsBase + public class GetServiceConfigTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/config"; - public GetServiceConfigTests(WebApplicationFactory factory) : base(factory) + public GetServiceConfigTests(WebApplicationFactory factory) : base(factory) { } @@ -22,7 +22,7 @@ public async Task GetServiceConfig_AppWithoutConfig_OK(string org, string app) string dataPathWithData = VersionPrefix(org, app); using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); ServiceConfiguration serviceConfigResponse = await response.Content.ReadAsAsync(); ServiceConfiguration serviceConfiguration = new ServiceConfiguration { RepositoryName = app, ServiceDescription = null, ServiceId = null, ServiceName = null }; @@ -38,7 +38,7 @@ public async Task GetServiceConfig_AppWithConfig_OK(string org, string app) string dataPathWithData = VersionPrefix(org, app); using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); ServiceConfiguration serviceConfigResponse = await response.Content.ReadAsAsync(); ServiceConfiguration serviceConfiguration = ServiceConfigurationUtils.GetServiceConfiguration(TestRepositoriesLocation, org, app, "testUser"); diff --git a/backend/tests/Designer.Tests/Controllers/ConfigController/SetServiceConfigTests.cs b/backend/tests/Designer.Tests/Controllers/ConfigController/SetServiceConfigTests.cs index 8eaadd8e1a9..9ea6f6a1e60 100644 --- a/backend/tests/Designer.Tests/Controllers/ConfigController/SetServiceConfigTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ConfigController/SetServiceConfigTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.ConfigController { - public class SetServiceConfigTests : DisagnerEndpointsTestsBase + public class SetServiceConfigTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/config"; - public SetServiceConfigTests(WebApplicationFactory factory) : base(factory) + public SetServiceConfigTests(WebApplicationFactory factory) : base(factory) { } @@ -28,7 +28,7 @@ public async Task SetServiceConfig_OK(string org, string app, string developer) using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, dataPathWithData); httpRequestMessage.Content = JsonContent.Create(new { serviceName = "Alternative-form-name", serviceDescription = "", serviceId = "" }); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); ServiceConfiguration serviceConfiguration = ServiceConfigurationUtils.GetServiceConfiguration(TestRepositoriesLocation, org, targetRepository, "testUser"); diff --git a/backend/tests/Designer.Tests/Controllers/DataModelsController/AddXsdTests.cs b/backend/tests/Designer.Tests/Controllers/DataModelsController/AddXsdTests.cs index f5b21171a32..4c79a5249ab 100644 --- a/backend/tests/Designer.Tests/Controllers/DataModelsController/AddXsdTests.cs +++ b/backend/tests/Designer.Tests/Controllers/DataModelsController/AddXsdTests.cs @@ -11,10 +11,10 @@ namespace Designer.Tests.Controllers.DataModelsController; -public class AddXsdTests : DisagnerEndpointsTestsBase +public class AddXsdTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/datamodels"; - public AddXsdTests(WebApplicationFactory factory) : base(factory) + public AddXsdTests(WebApplicationFactory factory) : base(factory) { } @@ -39,7 +39,7 @@ public async Task AddXsd_AppRepo_PreferredXsd_ShouldReturnCreated(string org, st Content = formData }; - var response = await HttpClient.Value.SendAsync(httpRequestMessage); + var response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.Created, response.StatusCode); } @@ -64,7 +64,7 @@ public async Task AddXsd_AppRepo_PreferredJson_ShouldReturnCreated(string org, s Content = formData }; - var response = await HttpClient.Value.SendAsync(httpRequestMessage); + var response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.Created, response.StatusCode); } @@ -89,7 +89,7 @@ public async Task AddXsd_DatamodelsRepo_NonAsciiName_ShouldReturnCreated(string Content = formData }; - var response = await HttpClient.Value.SendAsync(httpRequestMessage); + var response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.Created, response.StatusCode); } } diff --git a/backend/tests/Designer.Tests/Controllers/DataModelsController/DeleteDatamodelTests.cs b/backend/tests/Designer.Tests/Controllers/DataModelsController/DeleteDatamodelTests.cs index 6a064ad3586..d5a30c21f21 100644 --- a/backend/tests/Designer.Tests/Controllers/DataModelsController/DeleteDatamodelTests.cs +++ b/backend/tests/Designer.Tests/Controllers/DataModelsController/DeleteDatamodelTests.cs @@ -14,12 +14,12 @@ namespace Designer.Tests.Controllers.DataModelsController; -public class DeleteDatamodelTests : DisagnerEndpointsTestsBase +public class DeleteDatamodelTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/datamodels"; private readonly Mock _repositoryMock; - public DeleteDatamodelTests(WebApplicationFactory factory) : base(factory) + public DeleteDatamodelTests(WebApplicationFactory factory) : base(factory) { _repositoryMock = new Mock(); } @@ -40,7 +40,7 @@ public async Task Delete_Datamodel_Ok(string org, string repo, string modelPath) using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.NoContent); } } diff --git a/backend/tests/Designer.Tests/Controllers/DataModelsController/GetDatamodelsTests.cs b/backend/tests/Designer.Tests/Controllers/DataModelsController/GetDatamodelsTests.cs index 9bc87ece4de..d71f79c658a 100644 --- a/backend/tests/Designer.Tests/Controllers/DataModelsController/GetDatamodelsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/DataModelsController/GetDatamodelsTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.DataModelsController; -public class GetDatamodelsTests : DisagnerEndpointsTestsBase +public class GetDatamodelsTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/datamodels"; - public GetDatamodelsTests(WebApplicationFactory factory) : base(factory) + public GetDatamodelsTests(WebApplicationFactory factory) : base(factory) { } @@ -25,7 +25,7 @@ public async Task GetDatamodels_NoInput_ShouldReturnAllModels(string org, string using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - var response = await HttpClient.Value.SendAsync(httpRequestMessage); + var response = await HttpClient.SendAsync(httpRequestMessage); var altinnCoreFiles = await response.Content.ReadAsAsync>(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/DataModelsController/GetTests.cs b/backend/tests/Designer.Tests/Controllers/DataModelsController/GetTests.cs index 0d1c405656c..575837bf984 100644 --- a/backend/tests/Designer.Tests/Controllers/DataModelsController/GetTests.cs +++ b/backend/tests/Designer.Tests/Controllers/DataModelsController/GetTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.DataModelsController; -public class GetTests : DisagnerEndpointsTestsBase +public class GetTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/datamodels"; - public GetTests(WebApplicationFactory factory) : base(factory) + public GetTests(WebApplicationFactory factory) : base(factory) { } @@ -24,7 +24,7 @@ public async Task GetDatamodel_ValidPath_ShouldReturnContent(string modelPath, s string url = $"{VersionPrefix(org, repo)}/datamodel?modelPath={modelPath}"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); } } diff --git a/backend/tests/Designer.Tests/Controllers/DataModelsController/GetXsdDatamodelsTests.cs b/backend/tests/Designer.Tests/Controllers/DataModelsController/GetXsdDatamodelsTests.cs index f1ded858047..4d937f6116b 100644 --- a/backend/tests/Designer.Tests/Controllers/DataModelsController/GetXsdDatamodelsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/DataModelsController/GetXsdDatamodelsTests.cs @@ -11,10 +11,10 @@ namespace Designer.Tests.Controllers.DataModelsController; -public class GetXsdDatamodelsTests : DisagnerEndpointsTestsBase +public class GetXsdDatamodelsTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/datamodels"; - public GetXsdDatamodelsTests(WebApplicationFactory factory) : base(factory) + public GetXsdDatamodelsTests(WebApplicationFactory factory) : base(factory) { } @@ -26,7 +26,7 @@ public async Task GetXsdDatamodels_NoInput_ShouldReturnAllModels(string org, str var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - var response = await HttpClient.Value.SendAsync(httpRequestMessage); + var response = await HttpClient.SendAsync(httpRequestMessage); var altinnCoreFiles = await response.Content.ReadAsAsync>(); response.StatusCode.Should().Be(HttpStatusCode.OK); diff --git a/backend/tests/Designer.Tests/Controllers/DataModelsController/NonAuthenticatedCallsTests.cs b/backend/tests/Designer.Tests/Controllers/DataModelsController/NonAuthenticatedCallsTests.cs index 5b61e3a79a6..7be531de64e 100644 --- a/backend/tests/Designer.Tests/Controllers/DataModelsController/NonAuthenticatedCallsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/DataModelsController/NonAuthenticatedCallsTests.cs @@ -10,12 +10,12 @@ namespace Designer.Tests.Controllers.DataModelsController; -public class NonAuthenticatedCallsTests : DisagnerEndpointsTestsBase +public class NonAuthenticatedCallsTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/datamodels"; - private readonly WebApplicationFactory _factory; + private readonly WebApplicationFactory _factory; - public NonAuthenticatedCallsTests(WebApplicationFactory factory) : base(factory) + public NonAuthenticatedCallsTests(WebApplicationFactory factory) : base(factory) { _factory = factory; } @@ -27,7 +27,7 @@ public async Task GetDatamodels_NotAuthenticated_ShouldReturn401(string org, str string url = $"{VersionPrefix(org, repo)}/datamodel"; using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.Found, response.StatusCode); Assert.Contains("/login/", response.Headers.Location.AbsoluteUri.ToLower()); diff --git a/backend/tests/Designer.Tests/Controllers/DataModelsController/PostTests.cs b/backend/tests/Designer.Tests/Controllers/DataModelsController/PostTests.cs index 74b09ab3dcb..0e9b9610015 100644 --- a/backend/tests/Designer.Tests/Controllers/DataModelsController/PostTests.cs +++ b/backend/tests/Designer.Tests/Controllers/DataModelsController/PostTests.cs @@ -13,10 +13,10 @@ namespace Designer.Tests.Controllers.DataModelsController; -public class PostTests : DisagnerEndpointsTestsBase +public class PostTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/datamodels"; - public PostTests(WebApplicationFactory factory) : base(factory) + public PostTests(WebApplicationFactory factory) : base(factory) { } @@ -39,7 +39,7 @@ public async Task PostDatamodel_FromFormPost_ShouldReturnCreatedFromTemplate(str Content = JsonContent.Create(createViewModel, null, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }) }; - using var postResponse = await HttpClient.Value.SendAsync(postRequestMessage); + using var postResponse = await HttpClient.SendAsync(postRequestMessage); Assert.Equal(HttpStatusCode.Created, postResponse.StatusCode); Assert.Equal("application/json", postResponse.Content.Headers.ContentType.MediaType); @@ -52,7 +52,7 @@ public async Task PostDatamodel_FromFormPost_ShouldReturnCreatedFromTemplate(str // at the location provided in the post response var location = postResponse.Headers.Location; using var getRequestMessage = new HttpRequestMessage(HttpMethod.Get, location); - using var getResponse = await HttpClient.Value.SendAsync(getRequestMessage); + using var getResponse = await HttpClient.SendAsync(getRequestMessage); string getContent = await getResponse.Content.ReadAsStringAsync(); var getJsonSchema = JsonSchema.FromText(getContent); Assert.NotNull(getJsonSchema); @@ -77,7 +77,7 @@ public async Task PostDatamodel_InvalidFormPost_ShouldReturnBadRequest(string mo Content = JsonContent.Create(createViewModel, null, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }) }; - var postResponse = await HttpClient.Value.SendAsync(postRequestMessage); + var postResponse = await HttpClient.SendAsync(postRequestMessage); Assert.Equal(HttpStatusCode.BadRequest, postResponse.StatusCode); } diff --git a/backend/tests/Designer.Tests/Controllers/DataModelsController/PutDatamodelTests.cs b/backend/tests/Designer.Tests/Controllers/DataModelsController/PutDatamodelTests.cs index 72c1ee01f6e..6c596c12db1 100644 --- a/backend/tests/Designer.Tests/Controllers/DataModelsController/PutDatamodelTests.cs +++ b/backend/tests/Designer.Tests/Controllers/DataModelsController/PutDatamodelTests.cs @@ -31,14 +31,14 @@ namespace Designer.Tests.Controllers.DataModelsController; -public class PutDatamodelTests : DisagnerEndpointsTestsBase +public class PutDatamodelTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/datamodels"; private string TargetTestRepository { get; } private const string MinimumValidJsonSchema = "{\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"$id\":\"schema.json\",\"type\":\"object\",\"properties\":{\"root\":{\"$ref\":\"#/$defs/rootType\"}},\"$defs\":{\"rootType\":{\"properties\":{\"keyword\":{\"type\":\"string\"}}}}}"; - public PutDatamodelTests(WebApplicationFactory factory) : base(factory) + public PutDatamodelTests(WebApplicationFactory factory) : base(factory) { TargetTestRepository = TestDataHelper.GenerateTestRepoName(); } @@ -61,7 +61,7 @@ public async Task ValidInput_ShouldReturn_NoContent_And_Create_Files(string mode Content = new StringContent(MinimumValidJsonSchema, Encoding.UTF8, MediaTypeNames.Application.Json) }; - var response = await HttpClient.Value.SendAsync(request); + var response = await HttpClient.SendAsync(request); response.StatusCode.Should().Be(HttpStatusCode.NoContent); await FilesWithCorrectNameAndContentShouldBeCreated(modelName); } @@ -80,7 +80,7 @@ public async Task ValidSchema_ShouldReturn_NoContent_And_Create_Files(string mod Content = new StringContent(schema, Encoding.UTF8, MediaTypeNames.Application.Json) }; - var response = await HttpClient.Value.SendAsync(request); + var response = await HttpClient.SendAsync(request); response.StatusCode.Should().Be(HttpStatusCode.NoContent); } @@ -98,7 +98,7 @@ public async Task IncompatibleSchema_ShouldReturn422(string modelPath, string sc Content = new StringContent(schema, Encoding.UTF8, MediaTypeNames.Application.Json) }; - var response = await HttpClient.Value.SendAsync(request); + var response = await HttpClient.SendAsync(request); response.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); string content = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/DataModelsController/UseXsdFromRepoTests.cs b/backend/tests/Designer.Tests/Controllers/DataModelsController/UseXsdFromRepoTests.cs index 899c60ed17e..a40bf073be5 100644 --- a/backend/tests/Designer.Tests/Controllers/DataModelsController/UseXsdFromRepoTests.cs +++ b/backend/tests/Designer.Tests/Controllers/DataModelsController/UseXsdFromRepoTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.DataModelsController; -public class UseXsdFromRepoTests : DisagnerEndpointsTestsBase +public class UseXsdFromRepoTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/datamodels"; - public UseXsdFromRepoTests(WebApplicationFactory factory) : base(factory) + public UseXsdFromRepoTests(WebApplicationFactory factory) : base(factory) { } @@ -29,7 +29,7 @@ public async Task UseXsdFromRepo_DatamodelsRepo_ShouldReturnCreated(string org, using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.Created); } } diff --git a/backend/tests/Designer.Tests/Controllers/DeploymentsController/GetDeploymentsTests.cs b/backend/tests/Designer.Tests/Controllers/DeploymentsController/GetDeploymentsTests.cs index 5316c0cb42c..7ad7cae4747 100644 --- a/backend/tests/Designer.Tests/Controllers/DeploymentsController/GetDeploymentsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/DeploymentsController/GetDeploymentsTests.cs @@ -6,7 +6,6 @@ using System.Text.Json; using System.Threading.Tasks; using Altinn.Studio.Designer.Configuration; -using Altinn.Studio.Designer.Controllers; using Altinn.Studio.Designer.Repository.Models; using Altinn.Studio.Designer.Services.Interfaces; using Altinn.Studio.Designer.TypedHttpClients.AzureDevOps.Enums; @@ -19,11 +18,13 @@ using Moq; using Xunit; -public class GetDeployments : DisagnerEndpointsTestsBase +namespace Designer.Tests.Controllers.DeploymentsController; + +public class GetDeployments : DisagnerEndpointsTestsBase, IClassFixture> { private readonly Mock _deploymentServiceMock = new Mock(); private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/deployments"; - public GetDeployments(WebApplicationFactory factory) : base(factory) + public GetDeployments(WebApplicationFactory factory) : base(factory) { } @@ -50,7 +51,7 @@ public async Task GetDeployments_NoLaggingDeployments_PipelineServiceNotCalled(s using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); string responseString = await res.Content.ReadAsStringAsync(); SearchResults searchResult = JsonSerializer.Deserialize>(responseString, JsonSerializerOptions); IEnumerable actual = searchResult.Results; @@ -82,7 +83,7 @@ public async Task GetDeployments_SingleLaggingDeployments_PipelineServiceCalled( using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); string responseString = await res.Content.ReadAsStringAsync(); SearchResults searchResult = JsonSerializer.Deserialize>(responseString, JsonSerializerOptions); IEnumerable actual = searchResult.Results; diff --git a/backend/tests/Designer.Tests/Controllers/DeploymentsController/GetPermissionsTests.cs b/backend/tests/Designer.Tests/Controllers/DeploymentsController/GetPermissionsTests.cs index 2534cb7e49c..7ccbd86473d 100644 --- a/backend/tests/Designer.Tests/Controllers/DeploymentsController/GetPermissionsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/DeploymentsController/GetPermissionsTests.cs @@ -3,7 +3,6 @@ using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; -using Altinn.Studio.Designer.Controllers; using Altinn.Studio.Designer.RepositoryClient.Model; using Altinn.Studio.Designer.Services.Interfaces; using Designer.Tests.Controllers.ApiTests; @@ -12,12 +11,14 @@ using Moq; using Xunit; -public class GetPermissions : DisagnerEndpointsTestsBase +namespace Designer.Tests.Controllers.DeploymentsController; + +public class GetPermissions : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/deployments"; private readonly Mock _giteaMock; - public GetPermissions(WebApplicationFactory factory) : base(factory) + public GetPermissions(WebApplicationFactory factory) : base(factory) { _giteaMock = new Mock(); _giteaMock.Setup(g => g.GetUserNameFromUI()).ReturnsAsync("testUser"); @@ -45,7 +46,7 @@ public async Task GetPermissions_ToDeploymentsEnvironments_UserHasTeam_ReturnTea using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); string responseString = await res.Content.ReadAsStringAsync(); List permittedEnvironments = JsonSerializer.Deserialize>(responseString, JsonSerializerOptions); @@ -68,7 +69,7 @@ public async Task GetPermissions_ToDeploymentsEnvironments_UserHasNoTeam_ReturnE using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); string responseString = await res.Content.ReadAsStringAsync(); List permittedEnvironments = JsonSerializer.Deserialize>(responseString, JsonSerializerOptions); diff --git a/backend/tests/Designer.Tests/Controllers/LanguagesController/GetLanguagesTests.cs b/backend/tests/Designer.Tests/Controllers/LanguagesController/GetLanguagesTests.cs index 1c08fcce06b..3ea12406d08 100644 --- a/backend/tests/Designer.Tests/Controllers/LanguagesController/GetLanguagesTests.cs +++ b/backend/tests/Designer.Tests/Controllers/LanguagesController/GetLanguagesTests.cs @@ -9,11 +9,11 @@ namespace Designer.Tests.Controllers.LanguagesController { - public class GetLanguagesTests : DisagnerEndpointsTestsBase + public class GetLanguagesTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly string _versionPrefix = "designer/api"; - public GetLanguagesTests(WebApplicationFactory factory) : base(factory) + public GetLanguagesTests(WebApplicationFactory factory) : base(factory) { } @@ -23,7 +23,7 @@ public async Task GetLanguages_ReturnsNnAndNb() string dataPathWithData = $"{_versionPrefix}/ttd/new-texts-format/languages"; HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); JsonDocument responseDocument = JsonDocument.Parse(responseBody); diff --git a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetActionOptionsTests.cs b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetActionOptionsTests.cs index 94ee13a4f26..fead37e6809 100644 --- a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetActionOptionsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetActionOptionsTests.cs @@ -11,11 +11,11 @@ namespace Designer.Tests.Controllers.PolicyControllerTests { - public class GetActionOptionsTests : DisagnerEndpointsTestsBase + public class GetActionOptionsTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly string _versionPrefix = "designer/api"; - public GetActionOptionsTests(WebApplicationFactory factory) : base(factory) + public GetActionOptionsTests(WebApplicationFactory factory) : base(factory) { } @@ -30,7 +30,7 @@ public async Task Get_ActionOptions() using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData)) { - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); actionOptions = System.Text.Json.JsonSerializer.Deserialize>(responseBody, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); diff --git a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetAppPolicyTests.cs b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetAppPolicyTests.cs index 0181f13303b..69b1e556a70 100644 --- a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetAppPolicyTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetAppPolicyTests.cs @@ -10,11 +10,11 @@ namespace Designer.Tests.Controllers.PolicyControllerTests { - public class GetAppPolicyTests : DisagnerEndpointsTestsBase + public class GetAppPolicyTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly string _versionPrefix = "designer/api"; - public GetAppPolicyTests(WebApplicationFactory factory) : base(factory) + public GetAppPolicyTests(WebApplicationFactory factory) : base(factory) { } @@ -28,7 +28,7 @@ public async Task GetApp_AppPolicyOk() string dataPathWithData = $"{_versionPrefix}/ttd/{targetRepository}/policy"; using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData)) { - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); resourcePolicy = System.Text.Json.JsonSerializer.Deserialize(responseBody, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); diff --git a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetResourcePolicyTests.cs b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetResourcePolicyTests.cs index 854a92517e1..a1d0bc78371 100644 --- a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetResourcePolicyTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetResourcePolicyTests.cs @@ -10,11 +10,11 @@ namespace Designer.Tests.Controllers.PolicyControllerTests { - public class GetResourcePolicyTests : DisagnerEndpointsTestsBase + public class GetResourcePolicyTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly string _versionPrefix = "designer/api"; - public GetResourcePolicyTests(WebApplicationFactory factory) : base(factory) + public GetResourcePolicyTests(WebApplicationFactory factory) : base(factory) { } @@ -29,7 +29,7 @@ public async Task Get_ResourcePolicyOk() ResourcePolicy resourcePolicy; using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData)) { - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); resourcePolicy = System.Text.Json.JsonSerializer.Deserialize(responseBody, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); diff --git a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetSubjectOptionsTests.cs b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetSubjectOptionsTests.cs index 98cf98b61e6..e55971d4fd0 100644 --- a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetSubjectOptionsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/GetSubjectOptionsTests.cs @@ -11,11 +11,11 @@ namespace Designer.Tests.Controllers.PolicyControllerTests { - public class GetSubjectOptionsTests : DisagnerEndpointsTestsBase + public class GetSubjectOptionsTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly string _versionPrefix = "designer/api"; - public GetSubjectOptionsTests(WebApplicationFactory factory) : base(factory) + public GetSubjectOptionsTests(WebApplicationFactory factory) : base(factory) { } @@ -29,7 +29,7 @@ public async Task Get_SubjectOptions() List subjectionOptions; using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData)) { - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/UpdateApplicationPolicyTests.cs b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/UpdateApplicationPolicyTests.cs index e2dc9c242b1..b409c210921 100644 --- a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/UpdateApplicationPolicyTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/UpdateApplicationPolicyTests.cs @@ -11,11 +11,11 @@ namespace Designer.Tests.Controllers.PolicyControllerTests { - public class UpdateApplicationPolicyTests : DisagnerEndpointsTestsBase + public class UpdateApplicationPolicyTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly string _versionPrefix = "designer/api"; - public UpdateApplicationPolicyTests(WebApplicationFactory factory) : base(factory) + public UpdateApplicationPolicyTests(WebApplicationFactory factory) : base(factory) { } @@ -33,7 +33,7 @@ public async Task Update_AppPolicyOk() { httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(resourcePolicy), Encoding.UTF8, "application/json"); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); responseBody = await response.Content.ReadAsStringAsync(); } @@ -54,7 +54,7 @@ public async Task Create_ResourcePolicyOk() using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, dataPathWithData)) { httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(resourcePolicy), Encoding.UTF8, "application/json"); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); responseBody = await response.Content.ReadAsStringAsync(); } diff --git a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/UpdateResourcePolicyTests.cs b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/UpdateResourcePolicyTests.cs index 55c74c0632d..daa92e943c0 100644 --- a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/UpdateResourcePolicyTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/UpdateResourcePolicyTests.cs @@ -11,11 +11,11 @@ namespace Designer.Tests.Controllers.PolicyControllerTests { - public class UpdateResourcePolicyTests : DisagnerEndpointsTestsBase + public class UpdateResourcePolicyTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly string _versionPrefix = "designer/api"; - public UpdateResourcePolicyTests(WebApplicationFactory factory) : base(factory) + public UpdateResourcePolicyTests(WebApplicationFactory factory) : base(factory) { } @@ -32,7 +32,7 @@ public async Task Update_ResourcePolicyOk() using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, dataPathWithData)) { httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(resourcePolicy), Encoding.UTF8, "application/json"); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); responseBody = await response.Content.ReadAsStringAsync(); } diff --git a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/ValidateAppPolicyTests.cs b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/ValidateAppPolicyTests.cs index cf7069592a7..ab71d45580a 100644 --- a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/ValidateAppPolicyTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/ValidateAppPolicyTests.cs @@ -14,11 +14,11 @@ namespace Designer.Tests.Controllers.PolicyControllerTests { - public class ValidateAppPolicyTests : DisagnerEndpointsTestsBase + public class ValidateAppPolicyTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly string _versionPrefix = "designer/api"; - public ValidateAppPolicyTests(WebApplicationFactory factory) : base(factory) + public ValidateAppPolicyTests(WebApplicationFactory factory) : base(factory) { } @@ -33,7 +33,7 @@ public async Task Validate_AppPolicyOk() ValidationProblemDetails validationDetails; using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData)) { - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); validationDetails = System.Text.Json.JsonSerializer.Deserialize(responseBody, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); @@ -53,7 +53,7 @@ public async Task Validate_AppPolicyMissingSubject() ResourcePolicy resourcePolicy; using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData)) { - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); resourcePolicy = System.Text.Json.JsonSerializer.Deserialize(responseBody, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); @@ -68,7 +68,7 @@ public async Task Validate_AppPolicyMissingSubject() httpRequestMessage2.Content = new StringContent(JsonConvert.SerializeObject(resourcePolicy), Encoding.UTF8, "application/json"); - HttpResponseMessage response2 = await HttpClient.Value.SendAsync(httpRequestMessage2); + HttpResponseMessage response2 = await HttpClient.SendAsync(httpRequestMessage2); response2.EnsureSuccessStatusCode(); } @@ -77,7 +77,7 @@ public async Task Validate_AppPolicyMissingSubject() ValidationProblemDetails validationDetails; using (HttpRequestMessage httpRequestMessage3 = new HttpRequestMessage(HttpMethod.Get, dataPathWithData3)) { - HttpResponseMessage response3 = await HttpClient.Value.SendAsync(httpRequestMessage3); + HttpResponseMessage response3 = await HttpClient.SendAsync(httpRequestMessage3); string responseBody3 = await response3.Content.ReadAsStringAsync(); validationDetails = System.Text.Json.JsonSerializer.Deserialize(responseBody3, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); } diff --git a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/ValidateResourcePolicyTests.cs b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/ValidateResourcePolicyTests.cs index 55fd09061dc..d18c99da8f3 100644 --- a/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/ValidateResourcePolicyTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PolicyControllerTests/ValidateResourcePolicyTests.cs @@ -15,11 +15,11 @@ namespace Designer.Tests.Controllers.PolicyControllerTests { - public class ValidateResourcePolicyTests : DisagnerEndpointsTestsBase + public class ValidateResourcePolicyTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly string _versionPrefix = "designer/api"; - public ValidateResourcePolicyTests(WebApplicationFactory factory) : base(factory) + public ValidateResourcePolicyTests(WebApplicationFactory factory) : base(factory) { } @@ -34,7 +34,7 @@ public async Task Validate_ResourcePolicyOk() ValidationProblemDetails validationDetails; using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData)) { - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); validationDetails = System.Text.Json.JsonSerializer.Deserialize(responseBody, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); @@ -53,7 +53,7 @@ public async Task Validate_ResourcePolicyMissingSubject() ResourcePolicy resourcePolicy; using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData)) { - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); resourcePolicy = System.Text.Json.JsonSerializer.Deserialize(responseBody, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); @@ -66,7 +66,7 @@ public async Task Validate_ResourcePolicyMissingSubject() using (HttpRequestMessage httpRequestMessage2 = new HttpRequestMessage(HttpMethod.Put, dataPathWithData2)) { httpRequestMessage2.Content = new StringContent(JsonConvert.SerializeObject(resourcePolicy), Encoding.UTF8, "application/json"); - HttpResponseMessage response2 = await HttpClient.Value.SendAsync(httpRequestMessage2); + HttpResponseMessage response2 = await HttpClient.SendAsync(httpRequestMessage2); response2.EnsureSuccessStatusCode(); } @@ -75,7 +75,7 @@ public async Task Validate_ResourcePolicyMissingSubject() ValidationProblemDetails validationDetails; using (HttpRequestMessage httpRequestMessage3 = new HttpRequestMessage(HttpMethod.Get, dataPathWithData3)) { - HttpResponseMessage response3 = await HttpClient.Value.SendAsync(httpRequestMessage3); + HttpResponseMessage response3 = await HttpClient.SendAsync(httpRequestMessage3); string responseBody3 = await response3.Content.ReadAsStringAsync(); validationDetails = System.Text.Json.JsonSerializer.Deserialize(responseBody3, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); } @@ -96,7 +96,7 @@ public async Task Validate_ResourcePolicyMissingRules() ResourcePolicy resourcePolicy; using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData)) { - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); resourcePolicy = System.Text.Json.JsonSerializer.Deserialize(responseBody, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); @@ -109,7 +109,7 @@ public async Task Validate_ResourcePolicyMissingRules() using (HttpRequestMessage httpRequestMessage2 = new HttpRequestMessage(HttpMethod.Put, dataPathWithData2)) { httpRequestMessage2.Content = new StringContent(JsonConvert.SerializeObject(resourcePolicy), Encoding.UTF8, "application/json"); - HttpResponseMessage response2 = await HttpClient.Value.SendAsync(httpRequestMessage2); + HttpResponseMessage response2 = await HttpClient.SendAsync(httpRequestMessage2); response2.EnsureSuccessStatusCode(); } @@ -118,7 +118,7 @@ public async Task Validate_ResourcePolicyMissingRules() ValidationProblemDetails validationDetails; using (HttpRequestMessage httpRequestMessage3 = new HttpRequestMessage(HttpMethod.Get, dataPathWithData3)) { - HttpResponseMessage response3 = await HttpClient.Value.SendAsync(httpRequestMessage3); + HttpResponseMessage response3 = await HttpClient.SendAsync(httpRequestMessage3); string responseBody3 = await response3.Content.ReadAsStringAsync(); validationDetails = System.Text.Json.JsonSerializer.Deserialize(responseBody3, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); } diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/AnonymousTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/AnonymousTests.cs index 2b9ef5c8748..7ae976d4b4e 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/AnonymousTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/AnonymousTests.cs @@ -8,9 +8,9 @@ namespace Designer.Tests.Controllers.PreviewController { - public class AnonymousTests : PreviewControllerTestsBase + public class AnonymousTests : PreviewControllerTestsBase, IClassFixture> { - public AnonymousTests(WebApplicationFactory factory) : base(factory) + public AnonymousTests(WebApplicationFactory factory) : base(factory) { } @@ -20,7 +20,7 @@ public async Task Get_Anonymous_Ok() string dataPathWithData = $"{Org}/{App}/api/v1/data/anonymous"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationMetadataTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationMetadataTests.cs index 926a0429896..a1c143dbe3b 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationMetadataTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationMetadataTests.cs @@ -11,10 +11,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class ApplicationMetadataTests : PreviewControllerTestsBase + public class ApplicationMetadataTests : PreviewControllerTestsBase, IClassFixture> { - public ApplicationMetadataTests(WebApplicationFactory factory) : base(factory) + public ApplicationMetadataTests(WebApplicationFactory factory) : base(factory) { } @@ -26,7 +26,7 @@ public async Task Get_ApplicationMetadata_Ok() string dataPathWithData = $"{Org}/{App}/api/v1/applicationmetadata"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationSettingsTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationSettingsTests.cs index 52111c84a3c..97ab99d3bdb 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationSettingsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationSettingsTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class ApplicationSettingsTests : PreviewControllerTestsBase + public class ApplicationSettingsTests : PreviewControllerTestsBase, IClassFixture> { - public ApplicationSettingsTests(WebApplicationFactory factory) : base(factory) + public ApplicationSettingsTests(WebApplicationFactory factory) : base(factory) { } @@ -22,7 +22,7 @@ public async Task Get_ApplicationSettings_Ok() string dataPathWithData = $"{Org}/{App}/api/v1/applicationsettings"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/CurrentPartyTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/CurrentPartyTests.cs index c2b858af594..e5de392a79d 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/CurrentPartyTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/CurrentPartyTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class CurrentPartyTests : PreviewControllerTestsBase + public class CurrentPartyTests : PreviewControllerTestsBase, IClassFixture> { - public CurrentPartyTests(WebApplicationFactory factory) : base(factory) + public CurrentPartyTests(WebApplicationFactory factory) : base(factory) { } @@ -22,7 +22,7 @@ public async Task Get_CurrentParty_Ok() string dataPathWithData = $"{Org}/{App}/api/authorization/parties/current"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/CurrentUserTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/CurrentUserTests.cs index 858ea4d707e..141e4c754d3 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/CurrentUserTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/CurrentUserTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class CurrentUserTests : PreviewControllerTestsBase + public class CurrentUserTests : PreviewControllerTestsBase, IClassFixture> { - public CurrentUserTests(WebApplicationFactory factory) : base(factory) + public CurrentUserTests(WebApplicationFactory factory) : base(factory) { } @@ -22,7 +22,7 @@ public async Task Get_CurrentUser_Ok() string dataPathWithData = $"{Org}/{App}/api/v1/profile/user"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/DatamodelTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/DatamodelTests.cs index 2fca0fcfed2..51e0483fa40 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/DatamodelTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/DatamodelTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class DatamodelTests : PreviewControllerTestsBase + public class DatamodelTests : PreviewControllerTestsBase, IClassFixture> { - public DatamodelTests(WebApplicationFactory factory) : base(factory) + public DatamodelTests(WebApplicationFactory factory) : base(factory) { } @@ -24,7 +24,7 @@ public async Task Get_Datamodel_Ok() string dataPathWithData = $"{Org}/{App}/api/jsonschema/custom-dm-name"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/DeleteAttachmentTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/DeleteAttachmentTests.cs index 041bc9686bd..0ee46612cab 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/DeleteAttachmentTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/DeleteAttachmentTests.cs @@ -7,10 +7,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class DeleteAttachmentTests : PreviewControllerTestsBase + public class DeleteAttachmentTests : PreviewControllerTestsBase, IClassFixture> { - public DeleteAttachmentTests(WebApplicationFactory factory) : base(factory) + public DeleteAttachmentTests(WebApplicationFactory factory) : base(factory) { } @@ -21,7 +21,7 @@ public async Task Delete_Attachment_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Delete, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={App}&selectedLayoutSetInEditor="); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } @@ -32,7 +32,7 @@ public async Task Delete_AttachmentForStateFulApp_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Delete, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={StatefulApp}&selectedLayoutSetInEditor={LayoutSetName}"); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } } diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/GetApplicationLanguagesTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/GetApplicationLanguagesTests.cs index f414d3532a8..cb0afe6a658 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/GetApplicationLanguagesTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/GetApplicationLanguagesTests.cs @@ -6,10 +6,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class GetApplicationLanguagesTests : PreviewControllerTestsBase + public class GetApplicationLanguagesTests : PreviewControllerTestsBase, IClassFixture> { - public GetApplicationLanguagesTests(WebApplicationFactory factory) : base(factory) + public GetApplicationLanguagesTests(WebApplicationFactory factory) : base(factory) { } @@ -19,7 +19,7 @@ public async Task Get_ApplicationLanguages_Ok() string dataPathWithData = $"{Org}/{App}/api/v1/applicationlanguages"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormDataTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormDataTests.cs index 1ad7b51c9b1..ab77e8cb537 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormDataTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormDataTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class GetFormDataTests : PreviewControllerTestsBase + public class GetFormDataTests : PreviewControllerTestsBase, IClassFixture> { - public GetFormDataTests(WebApplicationFactory factory) : base(factory) + public GetFormDataTests(WebApplicationFactory factory) : base(factory) { } @@ -26,7 +26,7 @@ public async Task Get_FormData_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={App}&selectedLayoutSetInEditor="); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); @@ -40,7 +40,7 @@ public async Task Get_FormDataForAppWithoutDatamodel_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={App}&selectedLayoutSetInEditor="); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); @@ -56,7 +56,7 @@ public async Task Get_FormDataForStatefulApp_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={StatefulApp}&selectedLayoutSetInEditor={LayoutSetName}"); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); @@ -70,7 +70,7 @@ public async Task Get_FormDataForStatefulAppForTaskWithoutDatamodel_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={StatefulApp}&selectedLayoutSetInEditor={LayoutSetName2}"); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormLayoutsForStatefulApps.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormLayoutsForStatefulApps.cs index 74d73cc6f41..422dc04abbe 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormLayoutsForStatefulApps.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormLayoutsForStatefulApps.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class GetFormLayoutsForStatefulApps : PreviewControllerTestsBase + public class GetFormLayoutsForStatefulApps : PreviewControllerTestsBase, IClassFixture> { - public GetFormLayoutsForStatefulApps(WebApplicationFactory factory) : base(factory) + public GetFormLayoutsForStatefulApps(WebApplicationFactory factory) : base(factory) { } @@ -26,7 +26,7 @@ public async Task Get_FormLayoutsForStatefulApp_Ok() string dataPathWithData = $"{Org}/{StatefulApp}/api/layouts/{LayoutSetName}"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormLayoutsTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormLayoutsTests.cs index 24f72782368..af3bed38bd7 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormLayoutsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/GetFormLayoutsTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class GetFormLayoutsTests : PreviewControllerTestsBase + public class GetFormLayoutsTests : PreviewControllerTestsBase, IClassFixture> { - public GetFormLayoutsTests(WebApplicationFactory factory) : base(factory) + public GetFormLayoutsTests(WebApplicationFactory factory) : base(factory) { } @@ -25,7 +25,7 @@ public async Task Get_FormLayouts_Ok() string dataPathWithData = $"{Org}/{App}/api/resource/FormLayout.json"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/GetOptionsTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/GetOptionsTests.cs index 9fe6e82bc17..ee71fabd0b2 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/GetOptionsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/GetOptionsTests.cs @@ -7,10 +7,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class GetOptionsTests : PreviewControllerTestsBase + public class GetOptionsTests : PreviewControllerTestsBase, IClassFixture> { - public GetOptionsTests(WebApplicationFactory factory) : base(factory) + public GetOptionsTests(WebApplicationFactory factory) : base(factory) { } @@ -20,7 +20,7 @@ public async Task Get_Options_when_options_exists_Ok() string dataPathWithData = $"{Org}/{App}/api/options/test-options"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); @@ -34,7 +34,7 @@ public async Task Get_Options_when_options_exists_for_stateful_app_Ok() string dataPathWithData = $"{Org}/{StatefulApp}/instances/{PartyId}/{InstanceGuId}/options/test-options"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); @@ -48,7 +48,7 @@ public async Task Get_Options_when_no_options_exist_returns_NoContent() string dataPathWithData = $"{Org}/{App}/api/options/non-existing-options"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleConfigurationStatefulTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleConfigurationStatefulTests.cs index a5d169419f4..75316ea08e1 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleConfigurationStatefulTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleConfigurationStatefulTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class GetRuleConfigurationStatefulTests : PreviewControllerTestsBase + public class GetRuleConfigurationStatefulTests : PreviewControllerTestsBase, IClassFixture> { - public GetRuleConfigurationStatefulTests(WebApplicationFactory factory) : base(factory) + public GetRuleConfigurationStatefulTests(WebApplicationFactory factory) : base(factory) { } @@ -22,7 +22,7 @@ public async Task Get_RuleConfigurationForStatefulAppWithoutRuleConfig_NoContent string dataPathWithData = $"{Org}/{StatefulApp}/api/ruleconfiguration/{LayoutSetName}"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } @@ -34,7 +34,7 @@ public async Task Get_RuleConfigurationForStatefulAppWithRuleConfig_Ok() string dataPathWithData = $"{Org}/{StatefulApp}/api/ruleconfiguration/{LayoutSetName2}"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleConfigurationTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleConfigurationTests.cs index 530d696d96a..76833abc086 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleConfigurationTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleConfigurationTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class GetRuleConfigurationTests : PreviewControllerTestsBase + public class GetRuleConfigurationTests : PreviewControllerTestsBase, IClassFixture> { - public GetRuleConfigurationTests(WebApplicationFactory factory) : base(factory) + public GetRuleConfigurationTests(WebApplicationFactory factory) : base(factory) { } @@ -25,7 +25,7 @@ public async Task Get_RuleConfiguration_Ok() string dataPathWithData = $"{Org}/{appwithRuleConfig}/api/resource/RuleConfiguration.json"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); @@ -38,7 +38,7 @@ public async Task Get_RuleConfiguration_NoContent() string dataPathWithData = $"{Org}/{App}/api/resource/RuleConfiguration.json"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } } diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleHandlerStatefulTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleHandlerStatefulTests.cs index 3b63de474e4..4cc87dabbd6 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleHandlerStatefulTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleHandlerStatefulTests.cs @@ -6,10 +6,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class GetRuleHandlerStatefulTests : PreviewControllerTestsBase + public class GetRuleHandlerStatefulTests : PreviewControllerTestsBase, IClassFixture> { - public GetRuleHandlerStatefulTests(WebApplicationFactory factory) : base(factory) + public GetRuleHandlerStatefulTests(WebApplicationFactory factory) : base(factory) { } @@ -19,7 +19,7 @@ public async Task Get_RuleHandlerForStatefulAppWithoutRuleHandler_NoContent() string dataPathWithData = $"{Org}/{StatefulApp}/api/rulehandler/{LayoutSetName}"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } @@ -29,7 +29,7 @@ public async Task Get_RuleHandlerForStatefulAppWithRuleHandler_Ok() string dataPathWithData = $"{Org}/{StatefulApp}/api/rulehandler/{LayoutSetName2}"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } } diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleHandlerTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleHandlerTests.cs index 3c01980241f..7e4d723efe2 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleHandlerTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/GetRuleHandlerTests.cs @@ -6,10 +6,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class GetRuleHandlerTests : PreviewControllerTestsBase + public class GetRuleHandlerTests : PreviewControllerTestsBase, IClassFixture> { - public GetRuleHandlerTests(WebApplicationFactory factory) : base(factory) + public GetRuleHandlerTests(WebApplicationFactory factory) : base(factory) { } @@ -19,7 +19,7 @@ public async Task Get_RuleHandler_NoContent() string dataPathWithData = $"{Org}/{App}/api/resource/RuleHandler.js"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } } diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/InstanceForNextTaskTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/InstanceForNextTaskTests.cs index 54aaf8ca6e2..9f74248d81d 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/InstanceForNextTaskTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/InstanceForNextTaskTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class InstanceForNextTaskTests : PreviewControllerTestsBase + public class InstanceForNextTaskTests : PreviewControllerTestsBase, IClassFixture> { - public InstanceForNextTaskTests(WebApplicationFactory factory) : base(factory) + public InstanceForNextTaskTests(WebApplicationFactory factory) : base(factory) { } @@ -24,7 +24,7 @@ public async Task Get_InstanceForNextProcess_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={App}&selectedLayoutSetInEditor="); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); @@ -41,7 +41,7 @@ public async Task Get_InstanceForNextTaskForStatefulApp_Ok_TaskIsIncreased() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={StatefulApp}&selectedLayoutSetInEditor={LayoutSetName}"); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/InstancesTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/InstancesTests.cs index 09a0095aaf5..5e144a0be4d 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/InstancesTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/InstancesTests.cs @@ -11,10 +11,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class InstancesTests : PreviewControllerTestsBase + public class InstancesTests : PreviewControllerTestsBase, IClassFixture> { - public InstancesTests(WebApplicationFactory factory) : base(factory) + public InstancesTests(WebApplicationFactory factory) : base(factory) { } @@ -28,7 +28,7 @@ public async Task Post_Instance_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Post, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={App}&selectedLayoutSetInEditor="); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); @@ -48,7 +48,7 @@ public async Task Post_InstanceForStatefulApp_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Post, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={StatefulApp}&selectedLayoutSetInEditor={LayoutSetName}"); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/KeepAliveTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/KeepAliveTests.cs index 8b5954598d4..0119966ea1d 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/KeepAliveTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/KeepAliveTests.cs @@ -6,10 +6,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class KeepAliveTests : PreviewControllerTestsBase + public class KeepAliveTests : PreviewControllerTestsBase, IClassFixture> { - public KeepAliveTests(WebApplicationFactory factory) : base(factory) + public KeepAliveTests(WebApplicationFactory factory) : base(factory) { } @@ -19,7 +19,7 @@ public async Task Get_KeepAlive_Ok() string dataPathWithData = $"{Org}/{App}/api/authentication/keepAlive"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } } diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/LanguageTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/LanguageTests.cs index 943beca2601..c750011fac4 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/LanguageTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/LanguageTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class LanguageTests : PreviewControllerTestsBase + public class LanguageTests : PreviewControllerTestsBase, IClassFixture> { - public LanguageTests(WebApplicationFactory factory) : base(factory) + public LanguageTests(WebApplicationFactory factory) : base(factory) { } @@ -21,7 +21,7 @@ public async Task Get_Text_Ok() { string dataPathWithData = $"{Org}/{App}/api/v1/texts/nb"; - using HttpResponseMessage response = await HttpClient.Value.GetAsync(dataPathWithData); + using HttpResponseMessage response = await HttpClient.GetAsync(dataPathWithData); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSetsTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSetsTests.cs index 4ed787af04c..fa5e4f40414 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSetsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSetsTests.cs @@ -6,9 +6,9 @@ namespace Designer.Tests.Controllers.PreviewController { - public class LayoutSetsTests : PreviewControllerTestsBase + public class LayoutSetsTests : PreviewControllerTestsBase, IClassFixture> { - public LayoutSetsTests(WebApplicationFactory factory) : base(factory) + public LayoutSetsTests(WebApplicationFactory factory) : base(factory) { } @@ -18,7 +18,7 @@ public async Task Get_LayoutSets_NotFound() string dataPathWithData = $"{Org}/{App}/api/layoutsets"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } } diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSettingsForStatefulAppsTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSettingsForStatefulAppsTests.cs index 86fab42a4a9..c2e56429672 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSettingsForStatefulAppsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSettingsForStatefulAppsTests.cs @@ -9,9 +9,9 @@ namespace Designer.Tests.Controllers.PreviewController { - public class LayoutSettingsForStatefulAppsTests : PreviewControllerTestsBase + public class LayoutSettingsForStatefulAppsTests : PreviewControllerTestsBase, IClassFixture> { - public LayoutSettingsForStatefulAppsTests(WebApplicationFactory factory) : base(factory) + public LayoutSettingsForStatefulAppsTests(WebApplicationFactory factory) : base(factory) { } @@ -23,7 +23,7 @@ public async Task Get_LayoutSettingsForStatefulApps_Ok() string dataPathWithData = $"{Org}/{StatefulApp}/api/layoutsettings/{LayoutSetName}"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSettingsTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSettingsTests.cs index 018ab96a8ae..f00320d4511 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSettingsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/LayoutSettingsTests.cs @@ -9,9 +9,9 @@ namespace Designer.Tests.Controllers.PreviewController { - public class LayoutSettingsTests : PreviewControllerTestsBase + public class LayoutSettingsTests : PreviewControllerTestsBase, IClassFixture> { - public LayoutSettingsTests(WebApplicationFactory factory) : base(factory) + public LayoutSettingsTests(WebApplicationFactory factory) : base(factory) { } @@ -23,7 +23,7 @@ public async Task Get_LayoutSettings_Ok() string dataPathWithData = $"{Org}/{App}/api/layoutsettings"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/PostAttachmentTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/PostAttachmentTests.cs index c4755193cc7..cb4d8d55def 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/PostAttachmentTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/PostAttachmentTests.cs @@ -8,10 +8,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class PostAttachmentTests : PreviewControllerTestsBase + public class PostAttachmentTests : PreviewControllerTestsBase, IClassFixture> { - public PostAttachmentTests(WebApplicationFactory factory) : base(factory) + public PostAttachmentTests(WebApplicationFactory factory) : base(factory) { } @@ -22,7 +22,7 @@ public async Task Post_Attachment_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Post, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={App}&selectedLayoutSetInEditor="); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.Created, response.StatusCode); } @@ -33,7 +33,7 @@ public async Task Post_AttachmentForStateFulApp_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Post, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={StatefulApp}&selectedLayoutSetInEditor={LayoutSetName}"); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(StatusCodes.Status201Created, (int)response.StatusCode); } } diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/PreviewControllerTestsBase.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/PreviewControllerTestsBase.cs index d2054c16071..9975408005b 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/PreviewControllerTestsBase.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/PreviewControllerTestsBase.cs @@ -6,7 +6,7 @@ namespace Designer.Tests.Controllers.PreviewController { - public class PreviewControllerTestsBase : DisagnerEndpointsTestsBase + public class PreviewControllerTestsBase : DisagnerEndpointsTestsBase where TTestClass : class { protected const string Org = "ttd"; @@ -26,7 +26,7 @@ public class PreviewControllerTestsBase : DisagnerEndpointsTestsBase DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, }; - public PreviewControllerTestsBase(WebApplicationFactory factory) : base(factory) + public PreviewControllerTestsBase(WebApplicationFactory factory) : base(factory) { } diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/PreviewStatusTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/PreviewStatusTests.cs index cfe67dd0f90..201bb199f5e 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/PreviewStatusTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/PreviewStatusTests.cs @@ -6,10 +6,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class PreviewStatusTests : PreviewControllerTestsBase + public class PreviewStatusTests : PreviewControllerTestsBase, IClassFixture> { - public PreviewStatusTests(WebApplicationFactory factory) : base(factory) + public PreviewStatusTests(WebApplicationFactory factory) : base(factory) { } @@ -19,7 +19,7 @@ public async Task Get_PreviewStatus_Ok() string dataPathWithData = $"{Org}/{App}/preview/preview-status"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/ProcessNextTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/ProcessNextTests.cs index b4a58f28dc6..bbbe4f4fee5 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/ProcessNextTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/ProcessNextTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class ProcessNextTests : PreviewControllerTestsBase + public class ProcessNextTests : PreviewControllerTestsBase, IClassFixture> { - public ProcessNextTests(WebApplicationFactory factory) : base(factory) + public ProcessNextTests(WebApplicationFactory factory) : base(factory) { } @@ -24,7 +24,7 @@ public async Task Get_ProcessNext_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={App}&selectedLayoutSetInEditor="); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); @@ -41,7 +41,7 @@ public async Task Get_ProcessNextForStatefulApp_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={StatefulApp}&selectedLayoutSetInEditor={LayoutSetName}"); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/ProcessTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/ProcessTests.cs index 6aac8679f30..90d7c272297 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/ProcessTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/ProcessTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class ProcessTests : PreviewControllerTestsBase + public class ProcessTests : PreviewControllerTestsBase, IClassFixture> { - public ProcessTests(WebApplicationFactory factory) : base(factory) + public ProcessTests(WebApplicationFactory factory) : base(factory) { } @@ -24,7 +24,7 @@ public async Task Get_Process_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={App}&selectedLayoutSetInEditor="); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); @@ -41,7 +41,7 @@ public async Task Get_ProcessForStatefulApp_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={StatefulApp}&selectedLayoutSetInEditor={LayoutSetName}"); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/TextResourcesTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/TextResourcesTests.cs index d24d12f77c3..078c356fd2d 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/TextResourcesTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/TextResourcesTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class TextResourcesTests : PreviewControllerTestsBase + public class TextResourcesTests : PreviewControllerTestsBase, IClassFixture> { - public TextResourcesTests(WebApplicationFactory factory) : base(factory) + public TextResourcesTests(WebApplicationFactory factory) : base(factory) { } @@ -22,7 +22,7 @@ public async Task Get_TextResources_Ok() string dataPathWithData = $"{Org}/{App}/api/v1/textresources"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/UpdateFormDataTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/UpdateFormDataTests.cs index 6f72186f38f..485e674d1c1 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/UpdateFormDataTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/UpdateFormDataTests.cs @@ -7,10 +7,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class UpdateFormDataTests : PreviewControllerTestsBase + public class UpdateFormDataTests : PreviewControllerTestsBase, IClassFixture> { - public UpdateFormDataTests(WebApplicationFactory factory) : base(factory) + public UpdateFormDataTests(WebApplicationFactory factory) : base(factory) { } @@ -21,7 +21,7 @@ public async Task Put_UpdateFormData_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={App}&selectedLayoutSetInEditor="); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); } } diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/UpdateProcessNextTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/UpdateProcessNextTests.cs index 15640c07c00..df9441628bc 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/UpdateProcessNextTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/UpdateProcessNextTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class UpdateProcessNextTests : PreviewControllerTestsBase + public class UpdateProcessNextTests : PreviewControllerTestsBase, IClassFixture> { - public UpdateProcessNextTests(WebApplicationFactory factory) : base(factory) + public UpdateProcessNextTests(WebApplicationFactory factory) : base(factory) { } @@ -24,7 +24,7 @@ public async Task Put_ProcessNext_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={App}&selectedLayoutSetInEditor="); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); @@ -38,7 +38,7 @@ public async Task Put_ProcessNextForStatefulAppForNonExistingTask_Ok() using HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData); httpRequestMessage.Headers.Referrer = new Uri($"{MockedReferrerUrl}?org={Org}&app={StatefulApp}&selectedLayoutSetInEditor={LayoutSetName}"); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/ValidateInstantiationTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/ValidateInstantiationTests.cs index 49f2015b22e..72ee056b5a0 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/ValidateInstantiationTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/ValidateInstantiationTests.cs @@ -8,10 +8,10 @@ namespace Designer.Tests.Controllers.PreviewController { - public class ValidateInstantiationTests : PreviewControllerTestsBase + public class ValidateInstantiationTests : PreviewControllerTestsBase, IClassFixture> { - public ValidateInstantiationTests(WebApplicationFactory factory) : base(factory) + public ValidateInstantiationTests(WebApplicationFactory factory) : base(factory) { } @@ -21,7 +21,7 @@ public async Task Post_ValidateInstantiation_Ok() string dataPathWithData = $"{Org}/{App}/api/v1/parties/validateInstantiation"; using HttpRequestMessage httpRequestMessage = new(HttpMethod.Post, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetProcessDefinitionTests.cs b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetProcessDefinitionTests.cs index eef25a23b89..798f25ced22 100644 --- a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetProcessDefinitionTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetProcessDefinitionTests.cs @@ -12,11 +12,11 @@ namespace Designer.Tests.Controllers.ProcessModelingController { - public class GetProcessDefinitionTests : DisagnerEndpointsTestsBase + public class GetProcessDefinitionTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/process-modelling/process-definition"; - public GetProcessDefinitionTests(WebApplicationFactory factory) : base(factory) + public GetProcessDefinitionTests(WebApplicationFactory factory) : base(factory) { } @@ -31,7 +31,7 @@ public async Task GetProcessDefinitionTests_ShouldReturnOK(string org, string ap string url = VersionPrefix(org, targetRepository); using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await response.Content.ReadAsStringAsync(); @@ -48,7 +48,7 @@ public async Task GetProcessDefinitionTests_If_Doesnt_Exists_ShouldReturnNotFoun string url = VersionPrefix(org, app); using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); - using var response = await HttpClient.Value.SendAsync(httpRequestMessage); + using var response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.NotFound); } diff --git a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs index 989e0fbc7b8..aa4004264a5 100644 --- a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs @@ -9,11 +9,11 @@ namespace Designer.Tests.Controllers.ProcessModelingController { - public class GetTemplatesTests : DisagnerEndpointsTestsBase + public class GetTemplatesTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository, string appVersion) => $"/designer/api/{org}/{repository}/process-modelling/templates/{appVersion}"; - public GetTemplatesTests(WebApplicationFactory factory) : base(factory) + public GetTemplatesTests(WebApplicationFactory factory) : base(factory) { } @@ -24,7 +24,7 @@ public async Task GetTemplates_ShouldReturnOK(string org, string app, string ver { string url = VersionPrefix(org, app, version); - using var response = await HttpClient.Value.GetAsync(url); + using var response = await HttpClient.GetAsync(url); response.StatusCode.Should().Be(HttpStatusCode.OK); List responseContent = await response.Content.ReadAsAsync>(); diff --git a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs index 56cadd0f0f5..6cdd98524e9 100644 --- a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs @@ -9,12 +9,12 @@ namespace Designer.Tests.Controllers.ProcessModelingController { - public class SaveProcessDefinitionFromTemplateTests : DisagnerEndpointsTestsBase + public class SaveProcessDefinitionFromTemplateTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository, string appVersion, string templateName) => $"/designer/api/{org}/{repository}/process-modelling/templates/{appVersion}/{templateName}"; - public SaveProcessDefinitionFromTemplateTests(WebApplicationFactory factory) : base(factory) + public SaveProcessDefinitionFromTemplateTests(WebApplicationFactory factory) : base(factory) { } @@ -27,7 +27,7 @@ public async Task SaveProcessDefinitionFromTemplate_WrongTemplate_ShouldReturn40 string url = VersionPrefix(org, targetRepository, version, templateName); - using var response = await HttpClient.Value.PutAsync(url, null); + using var response = await HttpClient.PutAsync(url, null); response.StatusCode.Should().Be(HttpStatusCode.NotFound); } @@ -40,7 +40,7 @@ public async Task SaveProcessDefinitionFromTemplate_ShouldReturnOk_AndSaveTempla string url = VersionPrefix(org, targetRepository, version, templateName); - using var response = await HttpClient.Value.PutAsync(url, null); + using var response = await HttpClient.PutAsync(url, null); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionTests.cs b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionTests.cs index dd654d6eb86..4cfec77c98a 100644 --- a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionTests.cs @@ -13,11 +13,11 @@ namespace Designer.Tests.Controllers.ProcessModelingController { - public class SaveProcessDefinitionTests : DisagnerEndpointsTestsBase + public class SaveProcessDefinitionTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/process-modelling/process-definition"; - public SaveProcessDefinitionTests(WebApplicationFactory factory) : base(factory) + public SaveProcessDefinitionTests(WebApplicationFactory factory) : base(factory) { } @@ -32,7 +32,7 @@ public async Task SaveProcessDefinition_ShouldReturnOk(string org, string app, s string url = VersionPrefix(org, targetRepository); using var content = new StringContent(fileContent, Encoding.UTF8, MediaTypeNames.Application.Xml); - using var response = await HttpClient.Value.PutAsync(url, content); + using var response = await HttpClient.PutAsync(url, content); response.StatusCode.Should().Be(HttpStatusCode.OK); string savedFile = TestDataHelper.GetFileFromRepo(org, targetRepository, developer, "App/config/process/process.bpmn"); @@ -52,7 +52,7 @@ public async Task InvalidXml_ShouldReturnBadRequest(string org, string app, stri string url = VersionPrefix(org, targetRepository); using var content = new StringContent(nonXmlContent, Encoding.UTF8, MediaTypeNames.Application.Xml); - using var response = await HttpClient.Value.PutAsync(url, content); + using var response = await HttpClient.PutAsync(url, content); response.StatusCode.Should().Be(HttpStatusCode.BadRequest); } } diff --git a/backend/tests/Designer.Tests/Controllers/ReleasesController/GetTests.cs b/backend/tests/Designer.Tests/Controllers/ReleasesController/GetTests.cs index 5afc4c8622f..5bddad47621 100644 --- a/backend/tests/Designer.Tests/Controllers/ReleasesController/GetTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ReleasesController/GetTests.cs @@ -20,7 +20,7 @@ namespace Designer.Tests.Controllers.ReleasesController { - public class GetTests : DisagnerEndpointsTestsBase + public class GetTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly string _versionPrefix = "/designer/api"; private readonly JsonSerializerOptions _options; @@ -29,7 +29,7 @@ public class GetTests : DisagnerEndpointsTestsBase factory) : base(factory) + public GetTests(WebApplicationFactory factory) : base(factory) { _options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; _options.Converters.Add(new JsonStringEnumConverter()); @@ -56,7 +56,7 @@ public async Task GetReleases_NoLaggingReleases_PipelineServiceNotCalled() using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); string responseString = await res.Content.ReadAsStringAsync(); SearchResults searchResult = JsonSerializer.Deserialize>(responseString, _options); IEnumerable actual = searchResult.Results; @@ -87,7 +87,7 @@ public async Task GetReleases_SingleLaggingRelease_PipelineServiceCalled() using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); string responseString = await res.Content.ReadAsStringAsync(); SearchResults searchResult = JsonSerializer.Deserialize>(responseString, _options); IEnumerable actual = searchResult.Results; diff --git a/backend/tests/Designer.Tests/Controllers/RepositoryController/ContentsTests.cs b/backend/tests/Designer.Tests/Controllers/RepositoryController/ContentsTests.cs index cbf2de15348..e3b66f87400 100644 --- a/backend/tests/Designer.Tests/Controllers/RepositoryController/ContentsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/RepositoryController/ContentsTests.cs @@ -14,11 +14,11 @@ namespace Designer.Tests.Controllers.RepositoryController { - public class ContentsTests : DisagnerEndpointsTestsBase + public class ContentsTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly Mock _repositoryMock = new Mock(); private static string VersionPrefix => "/designer/api/repos"; - public ContentsTests(WebApplicationFactory factory) : base(factory) + public ContentsTests(WebApplicationFactory factory) : base(factory) { } @@ -52,7 +52,7 @@ public async Task Contents_ContentsReturned_OK() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); // Assert Assert.Equal(HttpStatusCode.OK, res.StatusCode); @@ -71,7 +71,7 @@ public async Task Contents_ContentsIsNull_BadRequest() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); // Assert Assert.Equal(HttpStatusCode.BadRequest, res.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/RepositoryController/CopyAppTests.cs b/backend/tests/Designer.Tests/Controllers/RepositoryController/CopyAppTests.cs index e56966d630e..9fe2f207a44 100644 --- a/backend/tests/Designer.Tests/Controllers/RepositoryController/CopyAppTests.cs +++ b/backend/tests/Designer.Tests/Controllers/RepositoryController/CopyAppTests.cs @@ -14,11 +14,11 @@ namespace Designer.Tests.Controllers.RepositoryController { - public class CopyAppTests : DisagnerEndpointsTestsBase + public class CopyAppTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly Mock _repositoryMock = new Mock(); private static string VersionPrefix => "/designer/api/repos"; - public CopyAppTests(WebApplicationFactory factory) : base(factory) + public CopyAppTests(WebApplicationFactory factory) : base(factory) { } @@ -43,7 +43,7 @@ public async Task CopyApp_RepoHasCreatedStatus_DeleteRepositoryIsNotCalled() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); // Assert _repositoryMock.VerifyAll(); @@ -59,7 +59,7 @@ public async Task CopyApp_TargetRepoAlreadyExists_ConflictIsReturned() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); // Assert Assert.Equal(HttpStatusCode.Conflict, res.StatusCode); @@ -81,7 +81,7 @@ public async Task CopyApp_GiteaTimeout_DeleteRepositoryIsCalled() HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, uri); // Act - HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); // Assert _repositoryMock.VerifyAll(); @@ -104,7 +104,7 @@ public async Task CopyApp_ExceptionIsThrownByService_InternalServerError() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); // Assert _repositoryMock.VerifyAll(); @@ -120,7 +120,7 @@ public async Task CopyApp_InvalidTargetRepoName_BadRequest() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); // Assert Assert.Equal(HttpStatusCode.BadRequest, res.StatusCode); @@ -135,7 +135,7 @@ public async Task CopyApp_InvalidSourceRepoName_BadRequest() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); string actual = await res.Content.ReadAsStringAsync(); // Assert diff --git a/backend/tests/Designer.Tests/Controllers/RepositoryController/CreateAppTests.cs b/backend/tests/Designer.Tests/Controllers/RepositoryController/CreateAppTests.cs index 843eca7e6da..8f98c53100a 100644 --- a/backend/tests/Designer.Tests/Controllers/RepositoryController/CreateAppTests.cs +++ b/backend/tests/Designer.Tests/Controllers/RepositoryController/CreateAppTests.cs @@ -13,11 +13,11 @@ namespace Designer.Tests.Controllers.RepositoryController { - public class CreateAppTests : DisagnerEndpointsTestsBase + public class CreateAppTests : DisagnerEndpointsTestsBase, IClassFixture> { private readonly Mock _repositoryMock = new Mock(); private static string VersionPrefix => "/designer/api/repos"; - public CreateAppTests(WebApplicationFactory factory) : base(factory) + public CreateAppTests(WebApplicationFactory factory) : base(factory) { } @@ -37,7 +37,7 @@ public async Task CreateApp_InvalidRepoName_BadRequest() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); // Assert Assert.Equal(HttpStatusCode.BadRequest, res.StatusCode); @@ -56,7 +56,7 @@ public async Task CreateApp_ValidRepoName_Created() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); // Assert Assert.Equal(HttpStatusCode.Created, res.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/RepositoryController/OrgReposTests.cs b/backend/tests/Designer.Tests/Controllers/RepositoryController/OrgReposTests.cs index 0f38aee1785..33f847697b7 100644 --- a/backend/tests/Designer.Tests/Controllers/RepositoryController/OrgReposTests.cs +++ b/backend/tests/Designer.Tests/Controllers/RepositoryController/OrgReposTests.cs @@ -7,10 +7,10 @@ namespace Designer.Tests.Controllers.RepositoryController { - public class OrgReposTests : DisagnerEndpointsTestsBase + public class OrgReposTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix => "/designer/api/repos"; - public OrgReposTests(WebApplicationFactory factory) : base(factory) + public OrgReposTests(WebApplicationFactory factory) : base(factory) { } @@ -23,7 +23,7 @@ public async Task OrgRepos_Returns200() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage); // Assert Assert.Equal(HttpStatusCode.OK, res.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/RepositoryController/ResetLocalRepositoryTests.cs b/backend/tests/Designer.Tests/Controllers/RepositoryController/ResetLocalRepositoryTests.cs index be6b5db9691..694e7fcbf39 100644 --- a/backend/tests/Designer.Tests/Controllers/RepositoryController/ResetLocalRepositoryTests.cs +++ b/backend/tests/Designer.Tests/Controllers/RepositoryController/ResetLocalRepositoryTests.cs @@ -13,10 +13,10 @@ namespace Designer.Tests.Controllers.RepositoryController { - public class ResetLocalRepositoryTests : DisagnerEndpointsTestsBase + public class ResetLocalRepositoryTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix => "/designer/api/repos"; - public ResetLocalRepositoryTests(WebApplicationFactory factory) : base(factory) + public ResetLocalRepositoryTests(WebApplicationFactory factory) : base(factory) { } @@ -42,7 +42,7 @@ public async Task ResetRepo_Returns200(string org, string repo, string developer string uri = $"{VersionPrefix}/repo/{org}/{targetRepository}/reset"; // Act - using HttpResponseMessage res = await HttpClient.Value.GetAsync(uri); + using HttpResponseMessage res = await HttpClient.GetAsync(uri); // Assert Assert.Equal(HttpStatusCode.OK, res.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/RepositorySettingsController/GetTests.cs b/backend/tests/Designer.Tests/Controllers/RepositorySettingsController/GetTests.cs index 417056c7b70..faa110f6395 100644 --- a/backend/tests/Designer.Tests/Controllers/RepositorySettingsController/GetTests.cs +++ b/backend/tests/Designer.Tests/Controllers/RepositorySettingsController/GetTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.RepositorySettingsController { - public class GetTests : DisagnerEndpointsTestsBase + public class GetTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/repository-settings"; - public GetTests(WebApplicationFactory factory) : base(factory) + public GetTests(WebApplicationFactory factory) : base(factory) { } @@ -21,7 +21,7 @@ public GetTests(WebApplicationFactory(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -33,7 +33,7 @@ public async Task Get_RepositorySettings_ShouldReturnOk(string org, string repo) public async Task Get_RepositoryDoesNotExists_ShouldReturnNotFound(string org, string repo) { string requestUrl = VersionPrefix(org, repo); - using HttpResponseMessage response = await HttpClient.Value.GetAsync(requestUrl); + using HttpResponseMessage response = await HttpClient.GetAsync(requestUrl); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); } diff --git a/backend/tests/Designer.Tests/Controllers/RepositorySettingsController/PutTests.cs b/backend/tests/Designer.Tests/Controllers/RepositorySettingsController/PutTests.cs index 6086b7a1e2e..2910c332e57 100644 --- a/backend/tests/Designer.Tests/Controllers/RepositorySettingsController/PutTests.cs +++ b/backend/tests/Designer.Tests/Controllers/RepositorySettingsController/PutTests.cs @@ -12,10 +12,10 @@ namespace Designer.Tests.Controllers.RepositorySettingsController { - public class PutTests : DisagnerEndpointsTestsBase + public class PutTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/repository-settings"; - public PutTests(WebApplicationFactory factory) : base(factory) + public PutTests(WebApplicationFactory factory) : base(factory) { } @@ -31,7 +31,7 @@ public async Task Put_ValidRepositorySettings_ShouldUpdate(string org, string re using var payload = new StringContent(requestBody, Encoding.UTF8, MediaTypeNames.Application.Json); - using HttpResponseMessage response = await HttpClient.Value.PutAsync(requestUrl, payload); + using HttpResponseMessage response = await HttpClient.PutAsync(requestUrl, payload); var altinnStudioSettings = await response.Content.ReadAsAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdmController/IndexTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdmController/IndexTests.cs index 106d2cd0d42..940f7507eec 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdmController/IndexTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdmController/IndexTests.cs @@ -7,9 +7,9 @@ namespace Designer.Tests.Controllers.ResourceAdmController { - public class IndexTests : DisagnerEndpointsTestsBase + public class IndexTests : DisagnerEndpointsTestsBase, IClassFixture> { - public IndexTests(WebApplicationFactory factory) : base(factory) + public IndexTests(WebApplicationFactory factory) : base(factory) { } @@ -20,7 +20,7 @@ public async Task GetResourceAdmIndexOK() string uri = $"/resourceadm/ttd/resources"; using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); string contenthtml = await res.Content.ReadAsStringAsync(); // Assert diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/AddResourceTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/AddResourceTests.cs index e8a0885f81b..5356586de8e 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/AddResourceTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/AddResourceTests.cs @@ -12,10 +12,10 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public class AddResourceTests : ResourceAdminControllerTestsBaseClass + public class AddResourceTests : ResourceAdminControllerTestsBaseClass, IClassFixture> { - public AddResourceTests(WebApplicationFactory factory) : base(factory) + public AddResourceTests(WebApplicationFactory factory) : base(factory) { } @@ -48,7 +48,7 @@ public async Task AddServiceResource_StatusCreated() httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(serviceResource), System.Text.Encoding.UTF8, "application/json"); //Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); //Assert RepositoryMock.VerifyAll(); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetAltinn2LinkServicesTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetAltinn2LinkServicesTests.cs index d1f9ee0a9ee..12f798cb039 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetAltinn2LinkServicesTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetAltinn2LinkServicesTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public class GetAltinn2LinkServicesTests : ResourceAdminControllerTestsBaseClass + public class GetAltinn2LinkServicesTests : ResourceAdminControllerTestsBaseClass, IClassFixture> { - public GetAltinn2LinkServicesTests(WebApplicationFactory factory) : base(factory) + public GetAltinn2LinkServicesTests(WebApplicationFactory factory) : base(factory) { } @@ -40,7 +40,7 @@ public async Task GetFilteredLinkServices() Altinn2MetadataClientMock.Setup(r => r.AvailableServices(It.IsAny(), It.IsAny())).ReturnsAsync(services); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.OK, res.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetGetLosTermsTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetGetLosTermsTests.cs index 1f2733b436e..a6486102114 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetGetLosTermsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetGetLosTermsTests.cs @@ -8,10 +8,10 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public class GetGetLosTermsTests : ResourceAdminControllerTestsBaseClass + public class GetGetLosTermsTests : ResourceAdminControllerTestsBaseClass, IClassFixture> { - public GetGetLosTermsTests(WebApplicationFactory factory) : base(factory) + public GetGetLosTermsTests(WebApplicationFactory factory) : base(factory) { } @@ -23,7 +23,7 @@ public async Task GetLosTerms() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); //Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); string sectorscontent = await res.Content.ReadAsStringAsync(); List losTerms = System.Text.Json.JsonSerializer.Deserialize>(sectorscontent, new System.Text.Json.JsonSerializerOptions() { PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase }); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetPublishStatusByIdTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetPublishStatusByIdTests.cs index f781ed27b18..0654a0674ec 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetPublishStatusByIdTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetPublishStatusByIdTests.cs @@ -10,9 +10,9 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public class GetPublishStatusByIdTests : ResourceAdminControllerTestsBaseClass + public class GetPublishStatusByIdTests : ResourceAdminControllerTestsBaseClass, IClassFixture> { - public GetPublishStatusByIdTests(WebApplicationFactory factory) : base(factory) + public GetPublishStatusByIdTests(WebApplicationFactory factory) : base(factory) { } @@ -47,7 +47,7 @@ public async Task GetResourceStatusById_Passing_Repository_OK() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.OK, res.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetRepositoryResourceListTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetRepositoryResourceListTests.cs index b8390f12d76..a0d920b0b95 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetRepositoryResourceListTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetRepositoryResourceListTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public class GetRepositoryResourceListTests : ResourceAdminControllerTestsBaseClass + public class GetRepositoryResourceListTests : ResourceAdminControllerTestsBaseClass, IClassFixture> { - public GetRepositoryResourceListTests(WebApplicationFactory factory) : base(factory) + public GetRepositoryResourceListTests(WebApplicationFactory factory) : base(factory) { } @@ -49,7 +49,7 @@ public async Task GetResourceList_OK() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.OK, res.StatusCode); @@ -67,7 +67,7 @@ public async Task GetResourceList_NoContent() .Returns(new List()); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.NoContent, res.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetRepositoryTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetRepositoryTests.cs index cf5f84475b9..3f9f8d751d0 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetRepositoryTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetRepositoryTests.cs @@ -6,9 +6,9 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public class GetRepositoryTests : ResourceAdminControllerTestsBaseClass + public class GetRepositoryTests : ResourceAdminControllerTestsBaseClass, IClassFixture> { - public GetRepositoryTests(WebApplicationFactory factory) : base(factory) + public GetRepositoryTests(WebApplicationFactory factory) : base(factory) { } @@ -20,7 +20,7 @@ public async Task GetResourceRepository_OK() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.OK, res.StatusCode); @@ -35,7 +35,7 @@ public async Task GetResourceRepository_NoContent() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.NoContent, res.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetResourceByIdTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetResourceByIdTests.cs index 2dcff737cc0..e39089abaa2 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetResourceByIdTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetResourceByIdTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public class GetResourceByIdTests : ResourceAdminControllerTestsBaseClass + public class GetResourceByIdTests : ResourceAdminControllerTestsBaseClass, IClassFixture> { - public GetResourceByIdTests(WebApplicationFactory factory) : base(factory) + public GetResourceByIdTests(WebApplicationFactory factory) : base(factory) { } @@ -47,7 +47,7 @@ public async Task GetResourceById_OK() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.OK, res.StatusCode); @@ -85,7 +85,7 @@ public async Task GetResourceById_Passing_Repository_OK() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.OK, res.StatusCode); @@ -100,7 +100,7 @@ public async Task GetResourceById_NoContent() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.NoContent, res.StatusCode); @@ -115,7 +115,7 @@ public async Task GetResourceById_Passing_Repository_NoContent() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.NoContent, res.StatusCode); @@ -130,7 +130,7 @@ public async Task GetResourceById_PassingNoValidArgument_NoContent() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.NoContent, res.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetSectorsTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetSectorsTests.cs index 8af8001075f..b39a5d2c1f9 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetSectorsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetSectorsTests.cs @@ -8,10 +8,10 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public class GetSectorsTests : ResourceAdminControllerTestsBaseClass + public class GetSectorsTests : ResourceAdminControllerTestsBaseClass, IClassFixture> { - public GetSectorsTests(WebApplicationFactory factory) : base(factory) + public GetSectorsTests(WebApplicationFactory factory) : base(factory) { } @@ -23,7 +23,7 @@ public async Task GetSectors() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); //Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); string sectorscontent = await res.Content.ReadAsStringAsync(); List dataThemes = System.Text.Json.JsonSerializer.Deserialize>(sectorscontent, new System.Text.Json.JsonSerializerOptions() { PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase }); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetValidateResourceTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetValidateResourceTests.cs index 421c4097798..f9ec01dca5c 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetValidateResourceTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/GetValidateResourceTests.cs @@ -7,10 +7,10 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public class GetValidateResourceTests : ResourceAdminControllerTestsBaseClass + public class GetValidateResourceTests : ResourceAdminControllerTestsBaseClass, IClassFixture> { - public GetValidateResourceTests(WebApplicationFactory factory) : base(factory) + public GetValidateResourceTests(WebApplicationFactory factory) : base(factory) { } @@ -24,7 +24,7 @@ public async Task ValidateServiceResourceById_IsValid() RepositoryMock.Setup(r => r.GetServiceResourceById(It.IsAny(), It.IsAny(), It.IsAny())).Returns(GetServiceResourceForValidationTest(true)); //Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); //Assert RepositoryMock.VerifyAll(); @@ -41,7 +41,7 @@ public async Task ValidateServiceResourceById_IsInValid() RepositoryMock.Setup(r => r.GetServiceResourceById(It.IsAny(), It.IsAny(), It.IsAny())).Returns(GetServiceResourceForValidationTest(false)); //Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); //Assert RepositoryMock.VerifyAll(); @@ -58,7 +58,7 @@ public async Task ValidateServiceResource_IsValid() RepositoryMock.Setup(r => r.GetServiceResources(It.IsAny(), It.IsAny(), It.IsAny())).Returns(GetServiceResourcesForValidationTest(true)); //Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); //Assert RepositoryMock.VerifyAll(); @@ -75,7 +75,7 @@ public async Task ValidateServiceResource_IsInValid() RepositoryMock.Setup(r => r.GetServiceResources(It.IsAny(), It.IsAny(), It.IsAny())).Returns(GetServiceResourcesForValidationTest(false)); //Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); //Assert RepositoryMock.VerifyAll(); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/ImportResourceTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/ImportResourceTests.cs index 0acdaf44a03..eea619b85ac 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/ImportResourceTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/ImportResourceTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public class ImportResourceTests : ResourceAdminControllerTestsBaseClass + public class ImportResourceTests : ResourceAdminControllerTestsBaseClass, IClassFixture> { - public ImportResourceTests(WebApplicationFactory factory) : base(factory) + public ImportResourceTests(WebApplicationFactory factory) : base(factory) { } @@ -35,7 +35,7 @@ public async Task ExportAltinn2Resource() Altinn2MetadataClientMock.Setup(r => r.GetXacmlPolicy(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(policy); // Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); // Assert Assert.Equal(HttpStatusCode.OK, res.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/ResourceAdminControllerTestsBaseClass.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/ResourceAdminControllerTestsBaseClass.cs index 7e153b9e6f7..281cd3c21ba 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/ResourceAdminControllerTestsBaseClass.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/ResourceAdminControllerTestsBaseClass.cs @@ -12,7 +12,7 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public abstract class ResourceAdminControllerTestsBaseClass : DisagnerEndpointsTestsBase where TTesetClass : class + public abstract class ResourceAdminControllerTestsBaseClass : DisagnerEndpointsTestsBase where TTesetClass : class { protected readonly string VersionPrefix = "/designer/api"; protected readonly Mock RepositoryMock; @@ -28,7 +28,7 @@ protected override void ConfigureTestServices(IServiceCollection services) services.AddTransient(_ => Altinn2MetadataClientMock.Object); } - protected ResourceAdminControllerTestsBaseClass(WebApplicationFactory factory) : base(factory) + protected ResourceAdminControllerTestsBaseClass(WebApplicationFactory factory) : base(factory) { RepositoryMock = new Mock(); Altinn2MetadataClientMock = new Mock(); diff --git a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/UpdateResourceTests.cs b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/UpdateResourceTests.cs index dc636c46fdf..11d1a31a7bf 100644 --- a/backend/tests/Designer.Tests/Controllers/ResourceAdminController/UpdateResourceTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ResourceAdminController/UpdateResourceTests.cs @@ -12,10 +12,10 @@ namespace Designer.Tests.Controllers.ResourceAdminController { - public class UpdateResourceTests : ResourceAdminControllerTestsBaseClass + public class UpdateResourceTests : ResourceAdminControllerTestsBaseClass, IClassFixture> { - public UpdateResourceTests(WebApplicationFactory factory) : base(factory) + public UpdateResourceTests(WebApplicationFactory factory) : base(factory) { } @@ -48,7 +48,7 @@ public async Task UpdateServiceResource_StatusCreated() httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(serviceResource), System.Text.Encoding.UTF8, "application/json"); //Act - using HttpResponseMessage res = await HttpClient.Value.SendAsync(httpRequestMessage).ConfigureAwait(false); + using HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage).ConfigureAwait(false); //Assert RepositoryMock.VerifyAll(); diff --git a/backend/tests/Designer.Tests/Controllers/SessionController/GetRemainingSessionTimeTests.cs b/backend/tests/Designer.Tests/Controllers/SessionController/GetRemainingSessionTimeTests.cs index 38b714e38c9..068ca7f1f21 100644 --- a/backend/tests/Designer.Tests/Controllers/SessionController/GetRemainingSessionTimeTests.cs +++ b/backend/tests/Designer.Tests/Controllers/SessionController/GetRemainingSessionTimeTests.cs @@ -14,10 +14,10 @@ namespace Designer.Tests.Controllers.SessionController { - public class GetRemainingSessionTimeTests : DisagnerEndpointsTestsBase + public class GetRemainingSessionTimeTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix => "/designer/api/session"; - public GetRemainingSessionTimeTests(WebApplicationFactory factory) : base(factory) + public GetRemainingSessionTimeTests(WebApplicationFactory factory) : base(factory) { } @@ -41,7 +41,7 @@ public async Task GetRemainingSessionTime_Ok() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseString = await response.Content.ReadAsStringAsync(); @@ -61,7 +61,7 @@ public async Task GetRemainingSessionTime_ExpiredCookie() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); string responseString = await response.Content.ReadAsStringAsync(); diff --git a/backend/tests/Designer.Tests/Controllers/SessionController/GetSessionDetailsTests.cs b/backend/tests/Designer.Tests/Controllers/SessionController/GetSessionDetailsTests.cs index 7e388c3afa8..b15a9fdee2b 100644 --- a/backend/tests/Designer.Tests/Controllers/SessionController/GetSessionDetailsTests.cs +++ b/backend/tests/Designer.Tests/Controllers/SessionController/GetSessionDetailsTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.SessionController { - public class GetSessionDetailsTests : DisagnerEndpointsTestsBase + public class GetSessionDetailsTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix => "/designer/api/session"; - public GetSessionDetailsTests(WebApplicationFactory factory) : base(factory) + public GetSessionDetailsTests(WebApplicationFactory factory) : base(factory) { } @@ -27,7 +27,7 @@ public async Task GetSessionDetails_ShouldReturn_Ok(params string[] expectedKeys using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/SessionController/KeepAliveTests.cs b/backend/tests/Designer.Tests/Controllers/SessionController/KeepAliveTests.cs index ce8a99903b7..1da7a57b14c 100644 --- a/backend/tests/Designer.Tests/Controllers/SessionController/KeepAliveTests.cs +++ b/backend/tests/Designer.Tests/Controllers/SessionController/KeepAliveTests.cs @@ -11,10 +11,10 @@ namespace Designer.Tests.Controllers.SessionController { - public class KeepAliveTests : DisagnerEndpointsTestsBase + public class KeepAliveTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix => "/designer/api/session"; - public KeepAliveTests(WebApplicationFactory factory) : base(factory) + public KeepAliveTests(WebApplicationFactory factory) : base(factory) { } @@ -27,7 +27,7 @@ public async Task KeepAlive_SessionIsExtended() using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); // Act - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/TextController/DeleteLanguageTests.cs b/backend/tests/Designer.Tests/Controllers/TextController/DeleteLanguageTests.cs index f487975202c..96ed22f408b 100644 --- a/backend/tests/Designer.Tests/Controllers/TextController/DeleteLanguageTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextController/DeleteLanguageTests.cs @@ -7,10 +7,10 @@ namespace Designer.Tests.Controllers.TextController { - public class DeleteLanguageTests : DisagnerEndpointsTestsBase + public class DeleteLanguageTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/text"; - public DeleteLanguageTests(WebApplicationFactory factory) : base(factory) + public DeleteLanguageTests(WebApplicationFactory factory) : base(factory) { } @@ -26,7 +26,7 @@ public async Task DeleteLanguage_WithValidInput_ReturnsOk(string org, string app .Should().BeTrue(); // Act - using var response = await HttpClient.Value.DeleteAsync(url); + using var response = await HttpClient.DeleteAsync(url); // Assert Assert.Equal(200, (int)response.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/TextController/GetLanguagesTests.cs b/backend/tests/Designer.Tests/Controllers/TextController/GetLanguagesTests.cs index 38468fe1d9a..8e0a7691f5b 100644 --- a/backend/tests/Designer.Tests/Controllers/TextController/GetLanguagesTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextController/GetLanguagesTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.TextController { - public class GetLanguagesTests : DisagnerEndpointsTestsBase + public class GetLanguagesTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/text"; - public GetLanguagesTests(WebApplicationFactory factory) : base(factory) + public GetLanguagesTests(WebApplicationFactory factory) : base(factory) { } @@ -25,7 +25,7 @@ public async Task GetLanguage_WithValidInput_ReturnsOk(string org, string app, p string expectedContent = JsonSerializer.Serialize(expectedLangs); // Act - using var response = await HttpClient.Value.GetAsync(url); + using var response = await HttpClient.GetAsync(url); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/TextController/GetResourceTests.cs b/backend/tests/Designer.Tests/Controllers/TextController/GetResourceTests.cs index 7bb19540ff8..74b528eb1b2 100644 --- a/backend/tests/Designer.Tests/Controllers/TextController/GetResourceTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextController/GetResourceTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.TextController { - public class GetResourceTests : DisagnerEndpointsTestsBase + public class GetResourceTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/text"; - public GetResourceTests(WebApplicationFactory factory) : base(factory) + public GetResourceTests(WebApplicationFactory factory) : base(factory) { } @@ -24,7 +24,7 @@ public async Task GetLanguage_WithValidInput_ReturnsOk(string org, string app, s string expectedContent = TestDataHelper.GetFileFromRepo(org, app, developer, $"App/config/texts/resource.{language}.json"); // Act - using var response = await HttpClient.Value.GetAsync(url); + using var response = await HttpClient.GetAsync(url); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -40,7 +40,7 @@ public async Task GetLanguage_WithNonExistingLang_ReturnsNotFound(string org, st string url = $"{VersionPrefix(org, app)}/language/{language}"; // Act - using var response = await HttpClient.Value.GetAsync(url); + using var response = await HttpClient.GetAsync(url); // Assert Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/TextController/GetServiceNameTests.cs b/backend/tests/Designer.Tests/Controllers/TextController/GetServiceNameTests.cs index ae3d1b4ff65..50363ff32d4 100644 --- a/backend/tests/Designer.Tests/Controllers/TextController/GetServiceNameTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextController/GetServiceNameTests.cs @@ -7,10 +7,10 @@ namespace Designer.Tests.Controllers.TextController { - public class GetServiceNameTests : DisagnerEndpointsTestsBase + public class GetServiceNameTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/text"; - public GetServiceNameTests(WebApplicationFactory factory) : base(factory) + public GetServiceNameTests(WebApplicationFactory factory) : base(factory) { } @@ -21,7 +21,7 @@ public async Task GetServiceName_WithValidInput_ReturnsOk(string org, string app string url = $"{VersionPrefix(org, app)}/service-name"; // Act - using var response = await HttpClient.Value.GetAsync(url); + using var response = await HttpClient.GetAsync(url); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/TextController/SaveResourceTests.cs b/backend/tests/Designer.Tests/Controllers/TextController/SaveResourceTests.cs index 22bdd2787c8..0c33d46d64a 100644 --- a/backend/tests/Designer.Tests/Controllers/TextController/SaveResourceTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextController/SaveResourceTests.cs @@ -12,10 +12,10 @@ namespace Designer.Tests.Controllers.TextController { - public class SaveResourceTests : DisagnerEndpointsTestsBase + public class SaveResourceTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/text"; - public SaveResourceTests(WebApplicationFactory factory) : base(factory) + public SaveResourceTests(WebApplicationFactory factory) : base(factory) { } @@ -31,7 +31,7 @@ public async Task SaveResource_WithValidInput_ReturnsOk(string org, string app, using var httpContent = new StringContent(payload, Encoding.UTF8, MediaTypeNames.Application.Json); // Act - using var response = await HttpClient.Value.PostAsync(url, httpContent); + using var response = await HttpClient.PostAsync(url, httpContent); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/TextController/UpdateTextsForKeysTests.cs b/backend/tests/Designer.Tests/Controllers/TextController/UpdateTextsForKeysTests.cs index 63d2f3dc295..7d4fe964fe4 100644 --- a/backend/tests/Designer.Tests/Controllers/TextController/UpdateTextsForKeysTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextController/UpdateTextsForKeysTests.cs @@ -16,10 +16,10 @@ namespace Designer.Tests.Controllers.TextController { - public class UpdateTextsForKeysTests : DisagnerEndpointsTestsBase + public class UpdateTextsForKeysTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/text"; - public UpdateTextsForKeysTests(WebApplicationFactory factory) : base(factory) + public UpdateTextsForKeysTests(WebApplicationFactory factory) : base(factory) { } @@ -48,7 +48,7 @@ public async Task UpdateTextsForKeys_WithValidInput_ReturnsOk(string org, string using var httpContent = new StringContent(JsonSerializer.Serialize(updateDictionary), Encoding.UTF8, MediaTypeNames.Application.Json); // Act - using HttpResponseMessage response = await HttpClient.Value.PutAsync(url, httpContent); + using HttpResponseMessage response = await HttpClient.PutAsync(url, httpContent); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -68,7 +68,7 @@ public async Task UpdateTextsForKeys_ForTextsThatHaveVariables_MaintainsVariable using var httpContent = new StringContent(JsonSerializer.Serialize(updateDictionary), Encoding.UTF8, MediaTypeNames.Application.Json); // Act - using HttpResponseMessage response = await HttpClient.Value.PutAsync(url, httpContent); + using HttpResponseMessage response = await HttpClient.PutAsync(url, httpContent); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); diff --git a/backend/tests/Designer.Tests/Controllers/TextKeysController/GetTests.cs b/backend/tests/Designer.Tests/Controllers/TextKeysController/GetTests.cs index a44994f018d..d636f714307 100644 --- a/backend/tests/Designer.Tests/Controllers/TextKeysController/GetTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextKeysController/GetTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.TextKeysController { - public class GetTests : DisagnerEndpointsTestsBase + public class GetTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/text-keys"; - public GetTests(WebApplicationFactory factory) : base(factory) + public GetTests(WebApplicationFactory factory) : base(factory) { } @@ -26,7 +26,7 @@ public async Task Get_Keys_200Ok(string org, string app, string developer, int e string dataPathWithData = VersionPrefix(org, targetRepository); HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); string content = await response.Content.ReadAsStringAsync(); @@ -44,7 +44,7 @@ public async Task GetKeys_TextsFilesNotFound_404NotFound(string org, string app, string dataPathWithData = VersionPrefix(org, targetRepository); HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(StatusCodes.Status404NotFound, (int)response.StatusCode); } @@ -57,7 +57,7 @@ public async Task GetKeys_TextsFileInvalidFormat_500InternalServerError(string o string dataPathWithData = VersionPrefix(org, targetRepository); HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(StatusCodes.Status500InternalServerError, (int)response.StatusCode); } diff --git a/backend/tests/Designer.Tests/Controllers/TextKeysController/PutTests.cs b/backend/tests/Designer.Tests/Controllers/TextKeysController/PutTests.cs index c4be6879ccc..8be5fd5b718 100644 --- a/backend/tests/Designer.Tests/Controllers/TextKeysController/PutTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextKeysController/PutTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.TextKeysController { - public class PutTests : DisagnerEndpointsTestsBase + public class PutTests : DisagnerEndpointsTestsBase, IClassFixture> { private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/text-keys"; - public PutTests(WebApplicationFactory factory) : base(factory) + public PutTests(WebApplicationFactory factory) : base(factory) { } @@ -26,11 +26,11 @@ public async Task PutNewKey_OldKeyPresentInAllFiles_200OkAndNewKeyPresent(string string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?oldKey=AlreadyExistingKey&newKey=ReplacedKey"; HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); string urlGetKeys = VersionPrefix(org, targetRepository); HttpRequestMessage urlGetKeysRequest = new(HttpMethod.Get, urlGetKeys); - HttpResponseMessage responseGetKeys = await HttpClient.Value.SendAsync(urlGetKeysRequest); - string list = responseGetKeys.Content.ReadAsStringAsync().Result; + HttpResponseMessage responseGetKeys = await HttpClient.SendAsync(urlGetKeysRequest); + string list = await responseGetKeys.Content.ReadAsStringAsync(); List keys = JsonSerializer.Deserialize>(list); Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); @@ -46,11 +46,11 @@ public async Task Put_NewKeyExistInOneFileOldKeyExistInAnotherFile_200OkAndOneLe string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?oldKey=KeyNotDefinedInEnglish&newKey=KeyOnlyDefinedInEnglish"; HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); string urlGetKeys = VersionPrefix(org, targetRepository); HttpRequestMessage urlGetKeysRequest = new(HttpMethod.Get, urlGetKeys); - HttpResponseMessage responseGetKeys = await HttpClient.Value.SendAsync(urlGetKeysRequest); - string list = responseGetKeys.Content.ReadAsStringAsync().Result; + HttpResponseMessage responseGetKeys = await HttpClient.SendAsync(urlGetKeysRequest); + string list = await responseGetKeys.Content.ReadAsStringAsync(); List keys = JsonSerializer.Deserialize>(list); Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); @@ -66,11 +66,11 @@ public async Task Put_NewKeyExistInSameFileAsOldKey_400BadRequestNoFilesChanged( string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?oldKey=AlreadyExistingKey&newKey=KeyOnlyDefinedInEnglish"; HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); string urlGetKeys = VersionPrefix(org, targetRepository); HttpRequestMessage urlGetKeysRequest = new(HttpMethod.Get, urlGetKeys); - HttpResponseMessage responseGetKeys = await HttpClient.Value.SendAsync(urlGetKeysRequest); - string list = responseGetKeys.Content.ReadAsStringAsync().Result; + HttpResponseMessage responseGetKeys = await HttpClient.SendAsync(urlGetKeysRequest); + string list = await responseGetKeys.Content.ReadAsStringAsync(); List keys = JsonSerializer.Deserialize>(list); Assert.Equal(StatusCodes.Status400BadRequest, (int)response.StatusCode); @@ -86,11 +86,11 @@ public async Task Put_EmptyNewKey_200OkOldKeyIsRemoved(string org, string app, s string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?oldKey=AlreadyExistingKey&newKey="; HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); string urlGetKeys = VersionPrefix(org, targetRepository); HttpRequestMessage urlGetKeysRequest = new(HttpMethod.Get, urlGetKeys); - HttpResponseMessage responseGetKeys = await HttpClient.Value.SendAsync(urlGetKeysRequest); - string list = responseGetKeys.Content.ReadAsStringAsync().Result; + HttpResponseMessage responseGetKeys = await HttpClient.SendAsync(urlGetKeysRequest); + string list = await responseGetKeys.Content.ReadAsStringAsync(); List keys = JsonSerializer.Deserialize>(list); Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); @@ -107,7 +107,7 @@ public async Task Put_TextsFilesNotFound_404NotFound(string org, string app, str string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?oldKey=KeyNotDefinedInEnglish&newKey=KeyOnlyDefinedInEnglish"; HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(StatusCodes.Status404NotFound, (int)response.StatusCode); } @@ -121,7 +121,7 @@ public async Task Put_IllegalArguments_400BadRequest(string org, string app, str string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?wrongQueryParam=KeyNotDefinedInEnglish&newKey=KeyOnlyDefinedInEnglish"; HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(StatusCodes.Status400BadRequest, (int)response.StatusCode); } diff --git a/backend/tests/Designer.Tests/Controllers/TextsController/ConvertTests.cs b/backend/tests/Designer.Tests/Controllers/TextsController/ConvertTests.cs index 20c82c40a29..c9838ff53f7 100644 --- a/backend/tests/Designer.Tests/Controllers/TextsController/ConvertTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextsController/ConvertTests.cs @@ -8,10 +8,10 @@ namespace Designer.Tests.Controllers.TextsController { - public class ConvertTests : DisagnerEndpointsTestsBase + public class ConvertTests : DisagnerEndpointsTestsBase, IClassFixture> { protected static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/texts"; - public ConvertTests(WebApplicationFactory factory) : base(factory) + public ConvertTests(WebApplicationFactory factory) : base(factory) { } @@ -23,7 +23,7 @@ public async Task Put_ConvertTexts_204NoContent(string org, string app, string d await CopyRepositoryForTest(org, app, developer, targetRepository); string dataPathWithData = $"{VersionPrefix(org, targetRepository)}/convert"; using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, dataPathWithData); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } diff --git a/backend/tests/Designer.Tests/Controllers/TextsController/DeleteTests.cs b/backend/tests/Designer.Tests/Controllers/TextsController/DeleteTests.cs index 816234f46de..5819a999324 100644 --- a/backend/tests/Designer.Tests/Controllers/TextsController/DeleteTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextsController/DeleteTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.TextsController { - public class DeleteTests : DisagnerEndpointsTestsBase + public class DeleteTests : DisagnerEndpointsTestsBase, IClassFixture> { protected static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/texts"; - public DeleteTests(WebApplicationFactory factory) : base(factory) + public DeleteTests(WebApplicationFactory factory) : base(factory) { } @@ -26,7 +26,7 @@ public async Task Delete_200Ok(string org, string app, string developer, string string dataPathWithData = $"{VersionPrefix(org, targetRepository)}/language/{lang}"; HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); string responseBody = await response.Content.ReadAsStringAsync(); JsonDocument responseDocument = JsonDocument.Parse(responseBody); diff --git a/backend/tests/Designer.Tests/Controllers/TextsController/GetTests.cs b/backend/tests/Designer.Tests/Controllers/TextsController/GetTests.cs index d80d3c0795e..36acfe117d3 100644 --- a/backend/tests/Designer.Tests/Controllers/TextsController/GetTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextsController/GetTests.cs @@ -9,10 +9,10 @@ namespace Designer.Tests.Controllers.TextsController { - public class GetTests : DisagnerEndpointsTestsBase + public class GetTests : DisagnerEndpointsTestsBase, IClassFixture> { protected static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/texts"; - public GetTests(WebApplicationFactory factory) : base(factory) + public GetTests(WebApplicationFactory factory) : base(factory) { } @@ -23,7 +23,7 @@ public async Task Get_ReturnsNbTexts(string org, string app, string lang) string dataPathWithData = $"{VersionPrefix(org, app)}/language/{lang}"; HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); JsonDocument responseDocument = JsonDocument.Parse(responseBody); @@ -42,7 +42,7 @@ public async Task Get_Markdown_200Ok(string org, string app, string lang) string dataPathWithData = $"{VersionPrefix(org, app)}/language/{lang}"; HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); } @@ -54,7 +54,7 @@ public async Task Get_NonExistingFile_404NotFound(string org, string app, string string dataPathWithData = $"{VersionPrefix(org, app)}/language/{lang}"; HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); string responseBody = await response.Content.ReadAsStringAsync(); JsonDocument responseDocument = JsonDocument.Parse(responseBody); @@ -69,7 +69,7 @@ public async Task Get_InvalidFile_500InternalServer(string org, string app, stri string dataPathWithData = $"{VersionPrefix(org, app)}/language/{lang}"; HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); string responseBody = await response.Content.ReadAsStringAsync(); JsonDocument responseDocument = JsonDocument.Parse(responseBody); Dictionary responseDictionary = JsonSerializer.Deserialize>(responseDocument.RootElement.ToString()); diff --git a/backend/tests/Designer.Tests/Controllers/TextsController/PutTests.cs b/backend/tests/Designer.Tests/Controllers/TextsController/PutTests.cs index 790c03c5e2a..85ea053cc3a 100644 --- a/backend/tests/Designer.Tests/Controllers/TextsController/PutTests.cs +++ b/backend/tests/Designer.Tests/Controllers/TextsController/PutTests.cs @@ -10,10 +10,10 @@ namespace Designer.Tests.Controllers.TextsController { - public class PutTests : DisagnerEndpointsTestsBase + public class PutTests : DisagnerEndpointsTestsBase, IClassFixture> { protected static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/texts"; - public PutTests(WebApplicationFactory factory) : base(factory) + public PutTests(WebApplicationFactory factory) : base(factory) { } @@ -31,7 +31,7 @@ public async Task Put_UpdateNbTexts_200OK(string org, string app, string develop new_key_2 = "new_value_2" }); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); } @@ -49,7 +49,7 @@ public async Task Put_Markdown_200OK(string org, string app, string developer, s markdown_key = "## This is a markdown text \n\n Here is a list \n - Item1 \n - Item2 \n - Item3 \n\n # HERE IS SOME IMPORTANT CODE \n `print(Hello world)`" }); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); } @@ -71,7 +71,7 @@ public async Task Put_UpdateInvalidFormat_400BadRequest(string org, string app, } }); - HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); string responseBody = await response.Content.ReadAsStringAsync(); JsonDocument responseDocument = JsonDocument.Parse(responseBody); diff --git a/backend/tests/Designer.Tests/GiteaIntegrationTests/GiteaIntegrationTestsBase.cs b/backend/tests/Designer.Tests/GiteaIntegrationTests/GiteaIntegrationTestsBase.cs index cb46cc32623..ae3f5cab693 100644 --- a/backend/tests/Designer.Tests/GiteaIntegrationTests/GiteaIntegrationTestsBase.cs +++ b/backend/tests/Designer.Tests/GiteaIntegrationTests/GiteaIntegrationTestsBase.cs @@ -19,8 +19,7 @@ namespace Designer.Tests.GiteaIntegrationTests { [Collection(nameof(GiteaCollection))] - public abstract class GiteaIntegrationTestsBase : ApiTestsBase, IDisposable - where TController : ControllerBase + public abstract class GiteaIntegrationTestsBase : ApiTestsBase where TControllerTest : class { protected readonly GiteaFixture GiteaFixture; @@ -40,8 +39,14 @@ protected void InvalidateAllCookies() } } - public void Dispose() + protected override void Dispose(bool disposing) { + base.Dispose(disposing); + if (!disposing) + { + return; + } + DeleteDirectoryIfExists(CreatedFolderPath); } @@ -67,7 +72,7 @@ protected override void ConfigureTestServices(IServiceCollection services) } - protected GiteaIntegrationTestsBase(WebApplicationFactory factory, GiteaFixture giteaFixture) : base(factory) + protected GiteaIntegrationTestsBase(WebApplicationFactory factory, GiteaFixture giteaFixture) : base(factory) { GiteaFixture = giteaFixture; } @@ -122,7 +127,7 @@ protected async Task CreateAppUsingDesigner(string org, string repoName) HttpMethod.Post, $"designer/api/repos/create-app?org={org}&repository={repoName}"); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.Created); InvalidateAllCookies(); } diff --git a/backend/tests/Designer.Tests/GiteaIntegrationTests/RepositoryControllerGiteaIntegrationTests.cs b/backend/tests/Designer.Tests/GiteaIntegrationTests/RepositoryControllerGiteaIntegrationTests.cs index e9114c4b118..49d211ab7c3 100644 --- a/backend/tests/Designer.Tests/GiteaIntegrationTests/RepositoryControllerGiteaIntegrationTests.cs +++ b/backend/tests/Designer.Tests/GiteaIntegrationTests/RepositoryControllerGiteaIntegrationTests.cs @@ -21,14 +21,14 @@ namespace Designer.Tests.GiteaIntegrationTests { - public class RepositoryControllerGiteaIntegrationTests : GiteaIntegrationTestsBase + public class RepositoryControllerGiteaIntegrationTests : GiteaIntegrationTestsBase, IClassFixture> { // Gitea needs some time to process changes to the repo, so we need to retry a few times private readonly AsyncRetryPolicy _giteaRetryPolicy = Policy.HandleResult(x => x.StatusCode != HttpStatusCode.OK) .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(retryAttempt)); - public RepositoryControllerGiteaIntegrationTests(WebApplicationFactory factory, GiteaFixture giteaFixture) : base(factory, giteaFixture) + public RepositoryControllerGiteaIntegrationTests(WebApplicationFactory factory, GiteaFixture giteaFixture) : base(factory, giteaFixture) { } @@ -58,7 +58,7 @@ public async Task Commit_AndPush_AndContents_ShouldBeAsExpected(string org) InvalidateAllCookies(); using var commitAndPushContent = new StringContent(GetCommitInfoJson("test commit", org, targetRepo), Encoding.UTF8, MediaTypeNames.Application.Json); - using HttpResponseMessage commitAndPushResponse = await HttpClient.Value.PostAsync($"designer/api/repos/repo/{org}/{targetRepo}/commit-and-push", commitAndPushContent); + using HttpResponseMessage commitAndPushResponse = await HttpClient.PostAsync($"designer/api/repos/repo/{org}/{targetRepo}/commit-and-push", commitAndPushContent); commitAndPushResponse.StatusCode.Should().Be(HttpStatusCode.OK); // Check if file is pushed to gitea @@ -67,7 +67,7 @@ public async Task Commit_AndPush_AndContents_ShouldBeAsExpected(string org) // Check contents with designer endpoint InvalidateAllCookies(); - using HttpResponseMessage contentsResponse = await HttpClient.Value.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/contents?path=test.txt"); + using HttpResponseMessage contentsResponse = await HttpClient.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/contents?path=test.txt"); contentsResponse.StatusCode.Should().Be(HttpStatusCode.OK); } @@ -83,11 +83,11 @@ public async Task Commit_AndPush_Separate_ShouldBeAsExpected(string org) InvalidateAllCookies(); await File.WriteAllTextAsync($"{CreatedFolderPath}/test3.txt", "I am a new file"); using var commitContent = new StringContent(GetCommitInfoJson("test commit", org, targetRepo), Encoding.UTF8, MediaTypeNames.Application.Json); - using HttpResponseMessage commitResponse = await HttpClient.Value.PostAsync($"designer/api/repos/repo/{org}/{targetRepo}/commit", commitContent); + using HttpResponseMessage commitResponse = await HttpClient.PostAsync($"designer/api/repos/repo/{org}/{targetRepo}/commit", commitContent); commitResponse.StatusCode.Should().Be(HttpStatusCode.OK); InvalidateAllCookies(); - using HttpResponseMessage pushResponse = await HttpClient.Value.PostAsync($"designer/api/repos/repo/{org}/{targetRepo}/push", null); + using HttpResponseMessage pushResponse = await HttpClient.PostAsync($"designer/api/repos/repo/{org}/{targetRepo}/push", null); pushResponse.StatusCode.Should().Be(HttpStatusCode.OK); // Check if file is pushed to gitea @@ -110,7 +110,7 @@ public async Task Pull_ShouldBeAsExpected(string org) // Try pull file with designer endpoint InvalidateAllCookies(); - using HttpResponseMessage pullResponse = await HttpClient.Value.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/pull"); + using HttpResponseMessage pullResponse = await HttpClient.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/pull"); pullResponse.StatusCode.Should().Be(HttpStatusCode.OK); // Check if file exists locally @@ -127,7 +127,7 @@ public async Task Initial_Commit_ShouldBeAsExpected(string org) // Check initial-commit endpoint InvalidateAllCookies(); - using HttpResponseMessage initialCommitResponse = await HttpClient.Value.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/initial-commit"); + using HttpResponseMessage initialCommitResponse = await HttpClient.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/initial-commit"); initialCommitResponse.StatusCode.Should().Be(HttpStatusCode.OK); var commit = await initialCommitResponse.Content.ReadAsAsync(); commit.Message.Should().Contain("App created"); @@ -143,14 +143,14 @@ public async Task MetadataAndStatus_ShouldBehaveAsExpected(string org) // Call metadata endpoint InvalidateAllCookies(); - using HttpResponseMessage metadataResponse = await HttpClient.Value.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/metadata"); + using HttpResponseMessage metadataResponse = await HttpClient.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/metadata"); metadataResponse.StatusCode.Should().Be(HttpStatusCode.OK); var deserializedRepositoryModel = await metadataResponse.Content.ReadAsAsync(); deserializedRepositoryModel.Name.Should().Be(targetRepo); // Call status endpoint InvalidateAllCookies(); - using HttpResponseMessage statusResponse = await HttpClient.Value.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/status"); + using HttpResponseMessage statusResponse = await HttpClient.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/status"); statusResponse.StatusCode.Should().Be(HttpStatusCode.OK); var deserializedRepoStatusModel = await statusResponse.Content.ReadAsAsync(); deserializedRepoStatusModel.RepositoryStatus.Should().Be(RepositoryStatus.Ok); @@ -166,7 +166,7 @@ public async Task GetOrgRepos_ShouldBehaveAsExpected(string org) // Call getOrgRepos endpoint InvalidateAllCookies(); - using HttpResponseMessage getOrgReposResponse = await HttpClient.Value.GetAsync($"designer/api/repos/org/{org}"); + using HttpResponseMessage getOrgReposResponse = await HttpClient.GetAsync($"designer/api/repos/org/{org}"); getOrgReposResponse.StatusCode.Should().Be(HttpStatusCode.OK); var deserializedRepositoryModel = await getOrgReposResponse.Content.ReadAsAsync>(); deserializedRepositoryModel.Should().NotBeEmpty(); @@ -186,7 +186,7 @@ public async Task GetBranches_And_Branch_ShouldBehaveAsExpected(string org) using HttpResponseMessage branchesResponse = await _giteaRetryPolicy.ExecuteAsync(async () => { InvalidateAllCookies(); - return await HttpClient.Value.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/branches"); + return await HttpClient.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/branches"); }); branchesResponse.StatusCode.Should().Be(HttpStatusCode.OK); var deserializedBranchesModel = await branchesResponse.Content.ReadAsAsync>(); @@ -197,7 +197,7 @@ public async Task GetBranches_And_Branch_ShouldBehaveAsExpected(string org) using HttpResponseMessage branchResponse = await _giteaRetryPolicy.ExecuteAsync(async () => { InvalidateAllCookies(); - return await HttpClient.Value.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/branches/branch?branch=master"); + return await HttpClient.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/branches/branch?branch=master"); }); branchResponse.StatusCode.Should().Be(HttpStatusCode.OK); } @@ -220,7 +220,7 @@ public async Task Commit_AndPush_NonPulled_ShouldReturnConflict(string org) // Add a file to local repo and try to push with designer await File.WriteAllTextAsync($"{CreatedFolderPath}/test.txt", "I am a new file from studio."); using var commitAndPushContent = new StringContent(GetCommitInfoJson("test commit", org, targetRepo), Encoding.UTF8, MediaTypeNames.Application.Json); - using HttpResponseMessage commitAndPushResponse = await HttpClient.Value.PostAsync($"designer/api/repos/repo/{org}/{targetRepo}/commit-and-push", commitAndPushContent); + using HttpResponseMessage commitAndPushResponse = await HttpClient.PostAsync($"designer/api/repos/repo/{org}/{targetRepo}/commit-and-push", commitAndPushContent); commitAndPushResponse.StatusCode.Should().Be(HttpStatusCode.Conflict); } diff --git a/backend/tests/Designer.Tests/GiteaIntegrationTests/UserControllerGiteaIntegrationTests.cs b/backend/tests/Designer.Tests/GiteaIntegrationTests/UserControllerGiteaIntegrationTests.cs index 4f2809c4f63..431d7e23daf 100644 --- a/backend/tests/Designer.Tests/GiteaIntegrationTests/UserControllerGiteaIntegrationTests.cs +++ b/backend/tests/Designer.Tests/GiteaIntegrationTests/UserControllerGiteaIntegrationTests.cs @@ -14,10 +14,10 @@ namespace Designer.Tests.GiteaIntegrationTests { - public class UserControllerGiteaIntegrationTests : GiteaIntegrationTestsBase + public class UserControllerGiteaIntegrationTests : GiteaIntegrationTestsBase, IClassFixture> { - public UserControllerGiteaIntegrationTests(WebApplicationFactory factory, GiteaFixture giteaFixture) : base(factory, giteaFixture) + public UserControllerGiteaIntegrationTests(WebApplicationFactory factory, GiteaFixture giteaFixture) : base(factory, giteaFixture) { } @@ -29,7 +29,7 @@ public async Task GetCurrentUser_ShouldReturnOk(string expectedUserName, string string requestUrl = "designer/api/user/current"; using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, requestUrl); - using HttpResponseMessage response = await HttpClient.Value.SendAsync(httpRequestMessage); + using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); response.Headers.First(h => h.Key == "Set-Cookie").Value.Should().Satisfy(e => e.Contains("XSRF-TOKEN")); @@ -52,7 +52,7 @@ public async Task UserRepos_ShouldReturnOk(string org) await CreateAppUsingDesigner(org, targetRepo); string requestUrl = $"designer/api/user/repos"; - using var response = await HttpClient.Value.GetAsync(requestUrl); + using var response = await HttpClient.GetAsync(requestUrl); response.StatusCode.Should().Be(HttpStatusCode.OK); var content = await response.Content.ReadAsAsync>(); content.Should().NotBeNull(); @@ -67,11 +67,11 @@ public async Task StarredEndpoints_ShouldBehaveAsExpected(string org) string targetRepo = TestDataHelper.GenerateTestRepoName(); await CreateAppUsingDesigner(org, targetRepo); - using var putStarredResponse = await HttpClient.Value.PutAsync($"designer/api/user/starred/{org}/{targetRepo}", null); + using var putStarredResponse = await HttpClient.PutAsync($"designer/api/user/starred/{org}/{targetRepo}", null); putStarredResponse.StatusCode.Should().Be(HttpStatusCode.NoContent); await GetAndVerifyStarredRepos(targetRepo); - using var deleteStarredResponse = await HttpClient.Value.DeleteAsync($"designer/api/user/starred/{org}/{targetRepo}"); + using var deleteStarredResponse = await HttpClient.DeleteAsync($"designer/api/user/starred/{org}/{targetRepo}"); deleteStarredResponse.StatusCode.Should().Be(HttpStatusCode.NoContent); await GetAndVerifyStarredRepos(); @@ -80,7 +80,7 @@ public async Task StarredEndpoints_ShouldBehaveAsExpected(string org) private async Task GetAndVerifyStarredRepos(params string[] expectedStarredRepos) { InvalidateAllCookies(); - using var response = await HttpClient.Value.GetAsync("designer/api/user/starred"); + using var response = await HttpClient.GetAsync("designer/api/user/starred"); response.StatusCode.Should().Be(HttpStatusCode.OK); var content = await response.Content.ReadAsAsync>(); content.Should().NotBeNull().And.HaveCount(expectedStarredRepos.Length); diff --git a/backend/tests/Designer.Tests/Properties/AssemblyInfo.cs b/backend/tests/Designer.Tests/Properties/AssemblyInfo.cs index a4bcec543f2..a5d1fd0ca24 100644 --- a/backend/tests/Designer.Tests/Properties/AssemblyInfo.cs +++ b/backend/tests/Designer.Tests/Properties/AssemblyInfo.cs @@ -1,3 +1,3 @@ using Xunit; -[assembly: CollectionBehavior(DisableTestParallelization = true)] +//[assembly: CollectionBehavior(DisableTestParallelization = true)] diff --git a/backend/tests/Designer.Tests/Utils/TestDataHelper.cs b/backend/tests/Designer.Tests/Utils/TestDataHelper.cs index fd3a426d951..5ffc9660c3a 100644 --- a/backend/tests/Designer.Tests/Utils/TestDataHelper.cs +++ b/backend/tests/Designer.Tests/Utils/TestDataHelper.cs @@ -151,7 +151,7 @@ public static string GenerateTestRepoName(string suffix = null, int length = 28) return suffix == null ? nonSuffixName : $"{nonSuffixName[..^suffix.Length]}{suffix}"; } - public async static Task CopyRepositoryForTest(string org, string repository, string developer, string targetRepsository) + public static async Task CopyRepositoryForTest(string org, string repository, string developer, string targetRepsository) { var sourceAppRepository = GetTestDataRepositoryDirectory(org, repository, developer); var targetDirectory = Path.Combine(GetTestDataRepositoriesRootDirectory(), developer, org, targetRepsository); @@ -245,7 +245,7 @@ public static string CreateEmptyRepositoryForTest(string org, string repository, return repositoryDirectory; } - public async static Task CopyDirectory(string sourceDirectory, string targetDirectory, bool copySubDirs = true) + public static async Task CopyDirectory(string sourceDirectory, string targetDirectory, bool copySubDirs = true) { DirectoryInfo sourceDirectoryInfo = new DirectoryInfo(sourceDirectory); @@ -259,23 +259,33 @@ public async static Task CopyDirectory(string sourceDirectory, string targetDire Directory.CreateDirectory(targetDirectory); FileInfo[] files = sourceDirectoryInfo.GetFiles(); - foreach (FileInfo file in files) + await Parallel.ForEachAsync(files, async (file, _) => { string tempPath = Path.Combine(targetDirectory, file.Name); - - var sourceBytes = ReadAllBytesWithoutLockingWithRetry(file.FullName); - await File.WriteAllBytesAsync(tempPath, sourceBytes); - File.SetAttributes(tempPath, FileAttributes.Normal); - } + await CopyFileIfNotExistsAsync(file, tempPath); + }); if (copySubDirs) { - foreach (DirectoryInfo subdir in sourceSubDirectories) + await Parallel.ForEachAsync(sourceSubDirectories, async (subDir, _) => { - string tempPath = Path.Combine(targetDirectory, subdir.Name); - await CopyDirectory(subdir.FullName, tempPath, copySubDirs); - } + string tempPath = Path.Combine(targetDirectory, subDir.Name); + await CopyDirectory(subDir.FullName, tempPath, copySubDirs); + }); + } + } + + // Copy file using Streams for better performance + private static async Task CopyFileIfNotExistsAsync(FileInfo file, string destinationPath) + { + if (File.Exists(destinationPath)) + { + return; } + await using FileStream sourceStream = file.OpenRead(); + await using FileStream destinationStream = File.Create(destinationPath, bufferSize: 4096, FileOptions.Asynchronous); + await sourceStream.CopyToAsync(destinationStream, bufferSize: 4096); + File.SetAttributes(destinationPath, FileAttributes.Normal); } public static void CleanUpRemoteRepository(string org, string repository)