Skip to content

Commit

Permalink
Addressing warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Psichorex committed Jan 20, 2024
1 parent 4ec8de8 commit b5bb1db
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 144 deletions.
2 changes: 1 addition & 1 deletion Lombiq.Tests.UI.Samples/Helpers/SetupHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static void AssertSetupSuccessful(UITestContext context)
{
var validationErrors = context.GetAll(By.ClassName("field-validation-error"));

if (!validationErrors.Any()) throw;
if (validationErrors.Count == 0) throw;

var errors = "\n- " + validationErrors.Select(element => element.Text.Trim()).Join("\n- ");
throw new AssertionException($"Setup has failed with the following validation errors:{errors}");
Expand Down
7 changes: 1 addition & 6 deletions Lombiq.Tests.UI.Samples/Tests/AccessibilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ namespace Lombiq.Tests.UI.Samples.Tests;
// Here we'll see how to check some web accessibility rules. Keeping our app accessible helps people with disabilities
// consume the content of our website more easily. Do note though that only checking rules that can be automatically
// checked is not enough for full compliance.
public class AccessibilityTest : UITestBase
public class AccessibilityTest(ITestOutputHelper testOutputHelper) : UITestBase(testOutputHelper)
{
public AccessibilityTest(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}

[Fact]
public Task FrontendPagesShouldBeAccessible() =>
ExecuteTestAfterSetupAsync(
Expand Down
7 changes: 1 addition & 6 deletions Lombiq.Tests.UI.Samples/Tests/AzureBlobStorageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ namespace Lombiq.Tests.UI.Samples.Tests;

// Up until now the Orchard app always used the default local Media storage for managing Media files. However, you may
// use Azure Blob Storage in production. You can also test your app with it!
public class AzureBlobStorageTests : UITestBase
public class AzureBlobStorageTests(ITestOutputHelper testOutputHelper) : UITestBase(testOutputHelper)
{
public AzureBlobStorageTests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}

// Here we have basically two of the same tests as in BasicTests but now we're using Azure Blob Storage as the
// site's Media storage. If they still work and there are no errors in the log then the app works with Azure Blob
// Storage too.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ namespace Lombiq.Tests.UI.Shortcuts.Controllers;
[ApiController]
[Route("api/ApplicationInfo")]
[DevelopmentAndLocalhostOnly]
public class ApplicationInfoController : Controller
public class ApplicationInfoController(IApplicationContext applicationContext) : Controller
{
private readonly IApplicationContext _applicationContext;

public ApplicationInfoController(IApplicationContext applicationContext) => _applicationContext = applicationContext;

[HttpGet]
public IActionResult Get() => Ok(_applicationContext.GetApplicationInfo());
public IActionResult Get() => Ok(applicationContext.GetApplicationInfo());
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,22 @@

namespace Lombiq.Tests.UI.Shortcuts.Services;

public class ApplicationInfoInjectingFilter : IAsyncResultFilter
public class ApplicationInfoInjectingFilter(
IResourceManager resourceManager,
IConfiguration shellConfiguration,
IApplicationContext applicationContext) : IAsyncResultFilter
{
private readonly IResourceManager _resourceManager;
private readonly IConfiguration _shellConfiguration;
private readonly IApplicationContext _applicationContext;

public ApplicationInfoInjectingFilter(
IResourceManager resourceManager,
IConfiguration shellConfiguration,
IApplicationContext applicationContext)
{
_resourceManager = resourceManager;
_shellConfiguration = shellConfiguration;
_applicationContext = applicationContext;
}

public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
{
if (context.IsNotFullViewRendering() || !_shellConfiguration.GetValue("Lombiq_Tests_UI:InjectApplicationInfo", defaultValue: false))
if (context.IsNotFullViewRendering() || !shellConfiguration.GetValue("Lombiq_Tests_UI:InjectApplicationInfo", defaultValue: false))
{
await next();
return;
}

_resourceManager.RegisterHeadScript(new HtmlString(
resourceManager.RegisterHeadScript(new HtmlString(
$"<!--{Environment.NewLine}" +
JsonConvert.SerializeObject(_applicationContext.GetApplicationInfo(), Formatting.Indented) +
JsonConvert.SerializeObject(applicationContext.GetApplicationInfo(), Formatting.Indented) +
Environment.NewLine +
"-->"));

Expand Down
2 changes: 1 addition & 1 deletion Lombiq.Tests.UI/SecurityScanning/ZapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public async Task<SecurityScanResult> RunSecurityScanAsync(

var cliParameters = new List<object> { "run" };

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
if (OperatingSystem.IsOSPlatform(nameof(OSPlatform.Linux)))
{
cliParameters.Add("--network");
cliParameters.Add("host");
Expand Down
2 changes: 1 addition & 1 deletion Lombiq.Tests.UI/Services/AtataFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Task<T> FromAsync<T>(Func<BrowserConfiguration, TimeSpan, Task<T>> factory)
var currentTry = 1;

// Force headless mode if we are in Linux without a working graphical environment.
if (!browserConfiguration.Headless && RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
if (!browserConfiguration.Headless && OperatingSystem.IsOSPlatform(nameof(OSPlatform.Linux)))
{
browserConfiguration.Headless = string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("DISPLAY"));
}
Expand Down
Loading

0 comments on commit b5bb1db

Please sign in to comment.