Skip to content

Commit

Permalink
Merge pull request #285 from Lombiq/issue/OSOE-628
Browse files Browse the repository at this point in the history
OSOE-628: Migrate RestEase usage to Refit in Lombiq.OrchardCoreApiClient
  • Loading branch information
Piedone authored Jun 13, 2023
2 parents d8997d5 + 39886d3 commit c0d153f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
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.WithNewtonsoftJson<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.3-alpha.1.osoe-628" />
<PackageReference Include="Lombiq.Npm.Targets" Version="1.3.0" />
</ItemGroup>

Expand Down

0 comments on commit c0d153f

Please sign in to comment.