diff --git a/ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs b/ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs index 31b9d64..9b6ab30 100644 --- a/ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs +++ b/ExternalMerlin.TUnit.RealDevices/DataDrivenTests.cs @@ -8,9 +8,9 @@ public class DataDrivenTests : SauceryTBase { [Test] [MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }])] - public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data) + public async Task DataDrivenTest(Func requestedPlatform, int data) { - InitialiseDriver(requestedPlatform); + InitialiseDriver(requestedPlatform()); var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/"); @@ -23,9 +23,13 @@ public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data) await Assert.That(commentText).Contains(data.ToString()); } - public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data) => from browserVersion in RequestedPlatformData.AllPlatformsAsList() - from datum in data - select (browserVersion, datum); + public static IEnumerable<(Func, int)> AllCombinations(int[] data) => + RequestedPlatformData + .AllPlatforms() + .SelectMany( + _ => data, + (browserVersionFunc, datum) => (browserVersionFunc, datum) + ); } /* diff --git a/ExternalMerlin.TUnit.RealDevices/RequestedPlatformData.cs b/ExternalMerlin.TUnit.RealDevices/RequestedPlatformData.cs index 110b17a..448b16b 100644 --- a/ExternalMerlin.TUnit.RealDevices/RequestedPlatformData.cs +++ b/ExternalMerlin.TUnit.RealDevices/RequestedPlatformData.cs @@ -20,7 +20,6 @@ static RequestedPlatformData() } public static List> AllPlatforms() => GetAllPlatformsAsFunc(); - public static List AllPlatformsAsList() => GetAllPlatformsAsList(); } /* * Copyright Andrew Gray, SauceForge diff --git a/ExternalMerlin.TUnit/DataDrivenTests.cs b/ExternalMerlin.TUnit/DataDrivenTests.cs index 06d27fc..d59e751 100644 --- a/ExternalMerlin.TUnit/DataDrivenTests.cs +++ b/ExternalMerlin.TUnit/DataDrivenTests.cs @@ -8,9 +8,9 @@ public class DataDrivenTests : SauceryTBase { [Test] [MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }])] - public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data) + public async Task DataDrivenTest(Func requestedPlatform, int data) { - InitialiseDriver(requestedPlatform); + InitialiseDriver(requestedPlatform()); var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/"); @@ -23,9 +23,14 @@ public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data) await Assert.That(commentText).Contains(data.ToString()); } - public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data) => from browserVersion in RequestedPlatformData.AllPlatformsAsList() - from datum in data - select (browserVersion, datum); + public static IEnumerable<(Func, int)> AllCombinations(int[] data) => + RequestedPlatformData + .AllPlatforms() + .SelectMany( + _ => data, + (browserVersionFunc, datum) => (browserVersionFunc, datum) + ); + } /* diff --git a/ExternalMerlin.TUnit/RequestedPlatformData.cs b/ExternalMerlin.TUnit/RequestedPlatformData.cs index fb8057c..5114b47 100644 --- a/ExternalMerlin.TUnit/RequestedPlatformData.cs +++ b/ExternalMerlin.TUnit/RequestedPlatformData.cs @@ -25,7 +25,6 @@ static RequestedPlatformData() } public static List> AllPlatforms() => GetAllPlatformsAsFunc(); - public static List AllPlatformsAsList() => GetAllPlatformsAsList(); } /* * Copyright Andrew Gray, SauceForge diff --git a/Merlin.TUnit.RealDevices/DataDrivenTests.cs b/Merlin.TUnit.RealDevices/DataDrivenTests.cs index 37efced..20a9932 100644 --- a/Merlin.TUnit.RealDevices/DataDrivenTests.cs +++ b/Merlin.TUnit.RealDevices/DataDrivenTests.cs @@ -8,9 +8,9 @@ public class DataDrivenTests : SauceryTBase { [Test] [MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }])] - public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data) + public async Task DataDrivenTest(Func requestedPlatform, int data) { - InitialiseDriver(requestedPlatform); + InitialiseDriver(requestedPlatform()); var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/"); @@ -23,9 +23,13 @@ public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data) await Assert.That(commentText).Contains(data.ToString()); } - public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data) => from browserVersion in RequestedPlatformData.AllPlatformsAsList() - from datum in data - select (browserVersion, datum); + public static IEnumerable<(Func, int)> AllCombinations(int[] data) => + RequestedPlatformData + .AllPlatforms() + .SelectMany( + _ => data, + (browserVersionFunc, datum) => (browserVersionFunc, datum) + ); } /* diff --git a/Merlin.TUnit.RealDevices/Merlin.TUnit.RealDevices.csproj b/Merlin.TUnit.RealDevices/Merlin.TUnit.RealDevices.csproj index 8f5e690..572294f 100644 --- a/Merlin.TUnit.RealDevices/Merlin.TUnit.RealDevices.csproj +++ b/Merlin.TUnit.RealDevices/Merlin.TUnit.RealDevices.csproj @@ -15,7 +15,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Merlin.TUnit.RealDevices/RequestedPlatformData.cs b/Merlin.TUnit.RealDevices/RequestedPlatformData.cs index 0326617..ca28be3 100644 --- a/Merlin.TUnit.RealDevices/RequestedPlatformData.cs +++ b/Merlin.TUnit.RealDevices/RequestedPlatformData.cs @@ -20,7 +20,6 @@ static RequestedPlatformData() } public static List> AllPlatforms() => GetAllPlatformsAsFunc(); - public static List AllPlatformsAsList() => GetAllPlatformsAsList(); } /* * Copyright Andrew Gray, SauceForge diff --git a/Merlin.TUnit/DataDrivenTests.cs b/Merlin.TUnit/DataDrivenTests.cs index 4c8bd33..f2051bb 100644 --- a/Merlin.TUnit/DataDrivenTests.cs +++ b/Merlin.TUnit/DataDrivenTests.cs @@ -8,9 +8,9 @@ public class DataDrivenTests : SauceryTBase { [Test] [MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }])] - public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data) + public async Task DataDrivenTest(Func requestedPlatform, int data) { - InitialiseDriver(requestedPlatform); + InitialiseDriver(requestedPlatform()); var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/"); @@ -23,9 +23,13 @@ public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data) await Assert.That(commentText).Contains(data.ToString()); } - public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data) => from browserVersion in RequestedPlatformData.AllPlatformsAsList() - from datum in data - select (browserVersion, datum); + public static IEnumerable<(Func, int)> AllCombinations(int[] data) => + RequestedPlatformData + .AllPlatforms() + .SelectMany( + _ => data, + (browserVersionFunc, datum) => (browserVersionFunc, datum) + ); } /* diff --git a/Merlin.TUnit/Merlin.TUnit.csproj b/Merlin.TUnit/Merlin.TUnit.csproj index f8e9115..46ab1f7 100644 --- a/Merlin.TUnit/Merlin.TUnit.csproj +++ b/Merlin.TUnit/Merlin.TUnit.csproj @@ -15,7 +15,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Merlin.TUnit/RequestedPlatformData.cs b/Merlin.TUnit/RequestedPlatformData.cs index 6c1f437..0227d4a 100644 --- a/Merlin.TUnit/RequestedPlatformData.cs +++ b/Merlin.TUnit/RequestedPlatformData.cs @@ -37,7 +37,6 @@ static RequestedPlatformData() } public static List> AllPlatforms() => GetAllPlatformsAsFunc(); - public static List AllPlatformsAsList() => GetAllPlatformsAsList(); } /* * Copyright Andrew Gray, SauceForge diff --git a/README.md b/README.md index cdaab15..abc558d 100644 --- a/README.md +++ b/README.md @@ -305,7 +305,7 @@ Your Project file should look something like this: - + @@ -322,15 +322,15 @@ using Saucery.Core.Dojo; using Saucery.Tests.Common.PageObjects; using Saucery.TUnit; -namespace ExternalMerlin.TUnit; +namespace Merlin.TUnit.RealDevices; public class DataDrivenTests : SauceryTBase { [Test] - [MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }]) - public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data) + [MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }])] + public async Task DataDrivenTest(Func requestedPlatform, int data) { - InitialiseDriver(requestedPlatform); + InitialiseDriver(requestedPlatform()); var guineaPigPage = new GuineaPigPage(SauceryDriver(), "https://saucelabs.com/"); @@ -338,14 +338,18 @@ public class DataDrivenTests : SauceryTBase var commentField = guineaPigPage.GetField(SauceryDriver(), "comments"); await Assert.That(commentField).IsNotNull(); - + var commentText = commentField.GetDomProperty("value"); await Assert.That(commentText).Contains(data.ToString()); } - public static IEnumerable<(BrowserVersion, int)> AllCombinations(int[] data) => from browserVersion in RequestedPlatformData.AllPlatformsAsList() - from datum in data - select (browserVersion, datum); + public static IEnumerable<(Func, int)> AllCombinations(int[] data) => + RequestedPlatformData + .AllPlatforms() + .SelectMany( + browserVersionFunc => data, + (browserVersionFunc, datum) => (browserVersionFunc, datum) + ); } ``` @@ -370,10 +374,10 @@ A data driven test is specified like this: ``` [Test] [MethodDataSource(nameof(AllCombinations), Arguments = [new[] { 4, 5 }])] -public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data) +public async Task DataDrivenTest(Func requestedPlatform, int data) ``` -You can call the class what you like but it must take a `BrowserVersion` and the `data` as a parameter and subclass `SauceryTBase`. +You can call the class what you like but it must take a `Func` and the `data` as a parameter and subclass `SauceryTBase`. `[MethodDataSource(nameof(AllCombinations)...]` is how you tell SauceryT what platforms you want to test on. You need to specify a class to do that. In this example its called `RequestedPlatformData` but you can call it anything you like. @@ -407,7 +411,6 @@ public class RequestedPlatformData : SauceryTestData } public static List> AllPlatforms() => GetAllPlatformsAsFunc(); - public static List AllPlatformsAsList() => GetAllPlatformsAsList(); ``` The `List` is what you will specify. The rest of the class is mandatory. Check out `SauceryConstants` for all the platform, browser and screenres enums. diff --git a/Sandbox.TUnit/Sandbox.TUnit.csproj b/Sandbox.TUnit/Sandbox.TUnit.csproj index 577ca0c..b5b7d25 100644 --- a/Sandbox.TUnit/Sandbox.TUnit.csproj +++ b/Sandbox.TUnit/Sandbox.TUnit.csproj @@ -8,7 +8,7 @@ - + diff --git a/Saucery.Core/DataSources/SauceryTestData.cs b/Saucery.Core/DataSources/SauceryTestData.cs index 2b58ac6..eda1a8e 100644 --- a/Saucery.Core/DataSources/SauceryTestData.cs +++ b/Saucery.Core/DataSources/SauceryTestData.cs @@ -31,25 +31,8 @@ protected static IEnumerable GetAllPlatforms() { return allPlatforms.AsEnumerable(); } - protected static List GetAllPlatformsAsList() - { - List allPlatforms = []; - allPlatforms.AddRange(from platform in Items - select platform); - return allPlatforms; - } - - protected static List> GetAllPlatformsAsFunc() - { - var listOfFunc = new List>(); - - foreach (var platform in Items) - { - listOfFunc.Add(() => platform); - } - - return listOfFunc; - } + protected static List> GetAllPlatformsAsFunc() => + Items.Select(platform => (Func)(() => platform)).ToList(); } /* * Copyright Andrew Gray, SauceForge diff --git a/Saucery.Core/Saucery.Core.csproj b/Saucery.Core/Saucery.Core.csproj index 676d203..e57c09b 100644 --- a/Saucery.Core/Saucery.Core.csproj +++ b/Saucery.Core/Saucery.Core.csproj @@ -26,7 +26,7 @@ - + diff --git a/Saucery.TUnit/Images/Saucery.TUnit.128x128.png b/Saucery.TUnit/Images/Saucery.TUnit.128x128.png index 057358d..4fe89ed 100644 Binary files a/Saucery.TUnit/Images/Saucery.TUnit.128x128.png and b/Saucery.TUnit/Images/Saucery.TUnit.128x128.png differ diff --git a/Saucery.TUnit/Images/Saucery.TUnit.128x128.xcf b/Saucery.TUnit/Images/Saucery.TUnit.128x128.xcf index 7bb8dda..c334aa3 100644 Binary files a/Saucery.TUnit/Images/Saucery.TUnit.128x128.xcf and b/Saucery.TUnit/Images/Saucery.TUnit.128x128.xcf differ diff --git a/Saucery.TUnit/Images/Saucery.TUnit.png b/Saucery.TUnit/Images/Saucery.TUnit.png index 8487740..f1f5cfe 100644 Binary files a/Saucery.TUnit/Images/Saucery.TUnit.png and b/Saucery.TUnit/Images/Saucery.TUnit.png differ diff --git a/Saucery.TUnit/Images/Saucery.TUnit.xcf b/Saucery.TUnit/Images/Saucery.TUnit.xcf index a50d347..faa25d3 100644 Binary files a/Saucery.TUnit/Images/Saucery.TUnit.xcf and b/Saucery.TUnit/Images/Saucery.TUnit.xcf differ diff --git a/Saucery.TUnit/Images/TUnitLogo 128x128.xcf b/Saucery.TUnit/Images/TUnitLogo 128x128.xcf new file mode 100644 index 0000000..47683f6 Binary files /dev/null and b/Saucery.TUnit/Images/TUnitLogo 128x128.xcf differ diff --git a/Saucery.TUnit/Images/TUnitLogo 2048x2048.xcf b/Saucery.TUnit/Images/TUnitLogo 2048x2048.xcf new file mode 100644 index 0000000..9123dd3 Binary files /dev/null and b/Saucery.TUnit/Images/TUnitLogo 2048x2048.xcf differ diff --git a/Saucery.TUnit/Images/TUnitLogo.png b/Saucery.TUnit/Images/TUnitLogo.png new file mode 100644 index 0000000..4c7d99d Binary files /dev/null and b/Saucery.TUnit/Images/TUnitLogo.png differ diff --git a/Saucery.TUnit/Images/tunit.128x128.png b/Saucery.TUnit/Images/tunit.128x128.png deleted file mode 100644 index 8d189d7..0000000 Binary files a/Saucery.TUnit/Images/tunit.128x128.png and /dev/null differ diff --git a/Saucery.TUnit/Images/tunit.256x256.png b/Saucery.TUnit/Images/tunit.256x256.png deleted file mode 100644 index d78255e..0000000 Binary files a/Saucery.TUnit/Images/tunit.256x256.png and /dev/null differ diff --git a/Saucery.TUnit/Images/tunit.svg b/Saucery.TUnit/Images/tunit.svg deleted file mode 100644 index 51cd7f1..0000000 --- a/Saucery.TUnit/Images/tunit.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Saucery.TUnit/Saucery.TUnit.csproj b/Saucery.TUnit/Saucery.TUnit.csproj index 8f6d582..7238f92 100644 --- a/Saucery.TUnit/Saucery.TUnit.csproj +++ b/Saucery.TUnit/Saucery.TUnit.csproj @@ -11,7 +11,7 @@ true Saucery.TUnit - 0.5.22 + 0.6.0 README.md Andrew Gray SauceForge @@ -29,8 +29,8 @@ - - + +