Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into feat/resharper
Browse files Browse the repository at this point in the history
  • Loading branch information
agray committed Dec 7, 2024
2 parents 306c82b + 0e07925 commit 97972be
Show file tree
Hide file tree
Showing 18 changed files with 362 additions and 18 deletions.
33 changes: 33 additions & 0 deletions Merlin.TUnit/ClickLinkTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Saucery.Core.Dojo;
using Saucery.Tests.Common.PageObjects;
using Saucery.TUnit;
using Shouldly;

namespace Merlin.TUnit;

public class ClickLinkTests : SauceryTBase
{
[Test]
[MethodDataSource(typeof(RequestedPlatformData), nameof(RequestedPlatformData.AllPlatforms))]
public async Task ClickLinkTest(
BrowserVersion requestedPlatform
)
{
//int i = 0;
//i++;

InitialiseDriver(requestedPlatform);

var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/");

guineaPigPage.ClickLink(SauceryDriver());

// verify the browser was navigated to the correct page
Driver!.Url.ShouldContain("saucelabs.com/test-guinea-pig2.html");
}
}
/*
* Copyright Andrew Gray, SauceForge
* Date: 16th April 2023
*
*/
27 changes: 27 additions & 0 deletions Merlin.TUnit/Merlin.TUnit.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="TUnit" Version="0.4.74" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Saucery.Core\Saucery.Core.csproj" />
<ProjectReference Include="..\Saucery.Tests.Common\Saucery.Tests.Common.csproj" />
<ProjectReference Include="..\Saucery.TUnit\Saucery.TUnit.csproj" />
</ItemGroup>

</Project>
45 changes: 45 additions & 0 deletions Merlin.TUnit/RequestedPlatformData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Saucery.Core.DataSources;
using Saucery.Core.Dojo;
using Saucery.Core.OnDemand;
using Saucery.Core.OnDemand.Base;
using Saucery.Core.Util;

namespace Merlin.TUnit;

public class RequestedPlatformData : SauceryTestData
{
static RequestedPlatformData()
{
var platforms = new List<SaucePlatform>
{
//Emulated Mobile Platforms
new AndroidPlatform("Google Pixel 8 Pro GoogleAPI Emulator", "15.0", SauceryConstants.DEVICE_ORIENTATION_PORTRAIT),
new IOSPlatform("iPhone 14 Pro Max Simulator", "16.2", SauceryConstants.DEVICE_ORIENTATION_LANDSCAPE),

//Desktop Platforms
new DesktopPlatform(SauceryConstants.PLATFORM_LINUX, SauceryConstants.BROWSER_CHROME, SauceryConstants.BROWSER_VERSION_LATEST),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_11, SauceryConstants.BROWSER_CHROME, "100->119", SauceryConstants.SCREENRES_2560_1600),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_10, SauceryConstants.BROWSER_CHROME, SauceryConstants.BROWSER_VERSION_LATEST, SauceryConstants.SCREENRES_2560_1600),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_81, SauceryConstants.BROWSER_CHROME, "100", SauceryConstants.SCREENRES_800_600),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_8, SauceryConstants.BROWSER_FIREFOX, "latest"),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_8, SauceryConstants.BROWSER_FIREFOX, "latest", SauceryConstants.SCREENRES_800_600),
new DesktopPlatform(SauceryConstants.PLATFORM_MAC_11, SauceryConstants.BROWSER_CHROME, SauceryConstants.BROWSER_VERSION_LATEST),
new DesktopPlatform(SauceryConstants.PLATFORM_MAC_12, SauceryConstants.BROWSER_CHROME, SauceryConstants.BROWSER_VERSION_LATEST),
new DesktopPlatform(SauceryConstants.PLATFORM_MAC_13, SauceryConstants.BROWSER_CHROME, SauceryConstants.BROWSER_VERSION_LATEST),
new DesktopPlatform(SauceryConstants.PLATFORM_MAC_1015, SauceryConstants.BROWSER_SAFARI, "15", SauceryConstants.SCREENRES_800_600),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_10, SauceryConstants.BROWSER_IE, "11"),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_10, SauceryConstants.BROWSER_IE, "11", SauceryConstants.SCREENRES_800_600),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_10, SauceryConstants.BROWSER_EDGE, "99"),
new DesktopPlatform(SauceryConstants.PLATFORM_WINDOWS_10, SauceryConstants.BROWSER_EDGE, "99", SauceryConstants.SCREENRES_800_600)
};

SetPlatforms(platforms);
}

public static IEnumerable<BrowserVersion> AllPlatforms() => (IEnumerable<BrowserVersion>)GetAllPlatforms();
}
/*
* Copyright Andrew Gray, SauceForge
* Date: 12th July 2024
*
*/
14 changes: 14 additions & 0 deletions Sandbox.TUnit/Sandbox.TUnit.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.13.1" />
<PackageReference Include="TUnit" Version="0.4.74" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions Sandbox.TUnit/Sandbox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Sandbox.TUnit
{
public class Sandbox
{
[Test]
public async Task MyTest()
{
var result = Add(1, 2);

await Assert.That(result).IsEqualTo(3);
}

private int Add(int x, int y)
{
return x + y;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NUnit.Framework;

namespace Saucery.Core.Tests.Issue1118.Base;
namespace Saucery.Core.Tests.NUnitIssue1118.Base;

[TestFixtureSource(typeof(SourceData))]
[Parallelizable(ParallelScope.All)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NUnit.Framework;
using Saucery.Core.Tests.Issue1118.Base;
using Saucery.Core.Tests.NUnitIssue1118.Base;

namespace Saucery.Core.Tests.Issue1118;
namespace Saucery.Core.Tests.NUnitIssue1118;

public class Fixture(string browser) : BaseClass(browser) {
[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NUnit.Framework;
using Saucery.Core.Tests.Issue1118.Base;
using Saucery.Core.Tests.NUnitIssue1118.Base;

namespace Saucery.Core.Tests.Issue1118;
namespace Saucery.Core.Tests.NUnitIssue1118;

public class Fixture2(string browser) : BaseClass(browser) {
[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections;
using Saucery.Core.Util;

namespace Saucery.Core.Tests.Issue1118;
namespace Saucery.Core.Tests.NUnitIssue1118;

public class SourceData : IEnumerable {
public IEnumerator GetEnumerator() {
Expand Down
4 changes: 1 addition & 3 deletions Saucery.Core.Tests/PlatformTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ private class PlatformDataClass {
new AndroidRealDevice("Google Pixel 6a", "12"),
new AndroidRealDevice("Google Pixel 4a", "11"),
new AndroidRealDevice("Google Pixel 4 XL", "10"),
new AndroidRealDevice("Samsung Galaxy Tab S4 10.5", "9"),
new AndroidRealDevice("OnePlus 5", "8"),
new AndroidRealDevice("Samsung Galaxy Tab S2", "7"),
new AndroidRealDevice("Samsung Galaxy Tab S4 10.5", "9")
];

public static List<SaucePlatform> RealIOSDevices =>
Expand Down
4 changes: 2 additions & 2 deletions Saucery.Core.Tests/RealAndroidFactoryVersionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public static IEnumerable SupportedTestCases
yield return new AndroidRealDevice("Google Pixel 4 XL", "10");
yield return new AndroidRealDevice("Samsung Galaxy Tab S3", "9");
//yield return new AndroidRealDevice("OnePlus 5", "8");
yield return new AndroidRealDevice("Samsung.*", "8"); //This shouldn't pass but does!
yield return new AndroidRealDevice("Samsung.*", "7");
//yield return new AndroidRealDevice("Samsung.*", "8"); //This shouldn't pass but does!
//yield return new AndroidRealDevice("Samsung.*", "7");
}
}

Expand Down
4 changes: 0 additions & 4 deletions Saucery.Core.Tests/Saucery.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Remove="LicenceTests.cs" />
</ItemGroup>

<ItemGroup>
<None Remove="consoleRun.bat" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Saucery.Core.Tests/TestFixtureSourceTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using Saucery.Core.Tests.Issue1118;
using Saucery.Core.Tests.NUnitIssue1118;

namespace Saucery.Core.Tests;

Expand Down
4 changes: 2 additions & 2 deletions Saucery.Core/Dojo/DojoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ public static PlatformBase FindAndroidPlatform(this List<PlatformBase> platforms
"Linux 11" => platforms.GetPlatform<Android11Platform>()[0],
"Linux 10" => platforms.GetPlatform<Android10Platform>()[0],
"Linux 9" => platforms.GetPlatform<Android9Platform>()[0],
"Linux 8" => platforms.GetPlatform<Android8Platform>()[0],
"Linux 7" => platforms.GetPlatform<Android7Platform>()[0],
//"Linux 8" => platforms.GetPlatform<Android8Platform>()[0],
//"Linux 7" => platforms.GetPlatform<Android7Platform>()[0],
_ => platform
};

Expand Down
76 changes: 76 additions & 0 deletions Saucery.TUnit/BaseFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.iOS;
using OpenQA.Selenium.Appium.Service;
using Saucery.Core.Dojo;
using Saucery.Core.Driver;
using Saucery.Core.OnDemand;
using Saucery.Core.Options;
using Saucery.Core.RestAPI.FlowControl;
using Saucery.Core.RestAPI.TestStatus;
using Saucery.Core.Util;

namespace Saucery.TUnit;

public class BaseFixture
{
public WebDriver? Driver;

internal readonly SauceLabsStatusNotifier SauceLabsStatusNotifier = new();

private readonly SauceLabsFlowController SauceLabsFlowController = new();

public OptionFactory? OptionFactory;

private readonly AppiumClientConfig AppiumClientConfig = new() { DirectConnect = true };

public bool InitialiseDriver((DriverOptions opts, BrowserVersion browserVersion) tuple, int waitSecs)
{
SauceLabsFlowController.ControlFlow(tuple.browserVersion.IsARealDevice());
try
{
Driver = OptionFactory!.IsApple()
? new IOSDriver(
new Uri(SauceryConstants.SAUCELABS_HUB),
tuple.opts,
TimeSpan.FromSeconds(waitSecs),
AppiumClientConfig)
: OptionFactory!.IsAndroid()
? new AndroidDriver(
new Uri(SauceryConstants.SAUCELABS_HUB),
tuple.opts,
TimeSpan.FromSeconds(waitSecs),
AppiumClientConfig)
: new SauceryRemoteWebDriver(
new Uri(SauceryConstants.SAUCELABS_HUB),
tuple.opts,
waitSecs);

return true;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}

//public void Dispose() {
// GC.SuppressFinalize(this);
// if (Driver is not null)
// {
// Driver.Quit();
// Driver.Dispose();
// }

// OptionFactory?.Dispose();
//}

public WebDriver SauceryDriver() =>
Driver!;
}
/*
* Copyright Andrew Gray, SauceForge
* Date: 7th December 2024
*
*/
22 changes: 22 additions & 0 deletions Saucery.TUnit/Saucery.TUnit.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="TUnit" Version="0.4.74" />
<PackageReference Include="TUnit.Core" Version="0.4.74" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Saucery.Core\Saucery.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Images\" />
</ItemGroup>

</Project>
Loading

0 comments on commit 97972be

Please sign in to comment.