Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-628: Migrate RestEase usage to Refit in Lombiq.OrchardCoreApiClient #285

Merged
merged 8 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Atata;
using Lombiq.HelpfulLibraries.OrchardCore.Mvc;
using Lombiq.HelpfulLibraries.Refit.Helpers;
using Lombiq.Tests.UI.Constants;
using Lombiq.Tests.UI.Exceptions;
using Lombiq.Tests.UI.Pages;
Expand All @@ -12,6 +12,7 @@
using OpenQA.Selenium;
using OrchardCore.Abstractions.Setup;
using OrchardCore.Admin;
using OrchardCore.Data;
using OrchardCore.DisplayManagement.Extensions;
using OrchardCore.Entities;
using OrchardCore.Environment.Extensions;
Expand All @@ -32,12 +33,11 @@
using OrchardCore.Workflows.Http.Models;
using OrchardCore.Workflows.Models;
using OrchardCore.Workflows.Services;
using RestEase;
using Refit;
using Shouldly;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Net.Http;
Expand Down Expand Up @@ -414,16 +414,18 @@ private static IShortcutsApi GetApi(this UITestContext context) =>
BaseAddress = context.Scope.BaseUri,
};

return RestClient.For<IShortcutsApi>(httpClient);
return RefitHelper.WithNewtonsoft<IShortcutsApi>(httpClient);
});

[SuppressMessage(
"StyleCop.CSharp.DocumentationRules",
"SA1600:Elements should be documented",
Justification = "Just maps to controller actions.")]
/// <summary>
/// A client interface for <c>Lombiq.Tests.UI.Shortcuts</c> web APIs.
/// </summary>
public interface IShortcutsApi
{
[Get("api/ApplicationInfo")]
/// <summary>
/// Sends a web request to <see cref="ApplicationInfoController.Get"/> endpoint.
/// </summary>
[Get("/api/ApplicationInfo")]
Task<ApplicationInfo> GetApplicationInfoFromApiAsync();
}

Expand Down Expand Up @@ -478,7 +480,7 @@ public static async Task CreateAndSwitchToTenantAsync(
{
setupParameters ??= new OrchardCoreSetupParameters(context);
var databaseProvider = setupParameters.DatabaseProvider == OrchardCoreSetupPage.DatabaseType.SqlServer
? OrchardCore.Data.DatabaseProviderValue.SqlConnection
? DatabaseProviderValue.SqlConnection
: setupParameters.DatabaseProvider.ToString();

await context.Application.UsingScopeAsync(
Expand Down
5 changes: 3 additions & 2 deletions Lombiq.Tests.UI/Lombiq.Tests.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<PackageReference Include="OrchardCore.Logging.NLog" Version="1.5.0" />
<PackageReference Include="OrchardCore.Abstractions" Version="1.5.0" />
<PackageReference Include="OrchardCore.Recipes.Core" Version="1.5.0" />
<PackageReference Include="Refit.HttpClientFactory" Version="6.3.2" />
<PackageReference Include="Selenium.Axe" Version="4.0.5" />
<PackageReference Include="Shouldly" Version="4.1.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
Expand All @@ -82,7 +83,7 @@
<ProjectReference Include="..\..\Lombiq.Tests\Lombiq.Tests.csproj" />
<ProjectReference Include="..\..\..\src\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.Cli\Lombiq.HelpfulLibraries.Cli.csproj" />
<ProjectReference Include="..\..\..\src\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.OrchardCore\Lombiq.HelpfulLibraries.OrchardCore.csproj" />
<ProjectReference Include="..\..\..\src\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.RestEase\Lombiq.HelpfulLibraries.RestEase.csproj" />
<ProjectReference Include="..\..\..\src\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.Refit\Lombiq.HelpfulLibraries.Refit.csproj" />
</ItemGroup>

<Import Condition="'$(NuGetBuild)' != 'true'" Project="..\..\..\src\Utilities\Lombiq.Npm.Targets\Lombiq.Npm.Targets.props" />
Expand All @@ -92,7 +93,7 @@
<PackageReference Include="Lombiq.Tests" Version="2.2.0" />
<PackageReference Include="Lombiq.HelpfulLibraries.Cli" Version="5.1.1" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="5.1.1" />
<PackageReference Include="Lombiq.HelpfulLibraries.RestEase" Version="5.1.1" />
<PackageReference Include="Lombiq.HelpfulLibraries.Refit" Version="5.1.1" />
Piedone marked this conversation as resolved.
Show resolved Hide resolved
<PackageReference Include="Lombiq.Npm.Targets" Version="1.3.0" />
</ItemGroup>

Expand Down