Skip to content

Commit

Permalink
try suggested approach
Browse files Browse the repository at this point in the history
  • Loading branch information
agray committed Dec 16, 2024
1 parent e94336d commit 12d8ef4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 51 deletions.
10 changes: 0 additions & 10 deletions Merlin.TUnit/DataDrivenData.cs

This file was deleted.

49 changes: 29 additions & 20 deletions Merlin.TUnit/DataDrivenTests.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
using Saucery.Core.Dojo;
using Saucery.Core.DataSources;
using Saucery.Core.Dojo;
using Saucery.Tests.Common.PageObjects;
using Saucery.TUnit;
using Shouldly;
using System.Drawing.Drawing2D;

namespace Merlin.TUnit;

public class DataDrivenTests : SauceryTBase
{
//[Test]
//public async Task ComboTest()
//{
// var combos = RequestedPlatformData.AllCombinations([4, 5]);
// var count = combos.Count;
// Console.WriteLine($"combos: {count}");
//}


[Test]
//[MethodDataSource(nameof(AllCombinations))]
//[MethodDataSource(typeof(RequestedPlatformData), nameof(RequestedPlatformData.AllCombinations([4,5])))]

//public async Task DataDrivenTest(DataDrivenData dataDrivenData)
public async Task DataDrivenTest(
[Matrix(nameof(RequestedPlatformData.AllPlatformsAsList))] BrowserVersion requestedPlatform,
[Matrix(4, 5)] int data)
[MethodDataSource(nameof(AllCombinations))]
public async Task DataDrivenTest(BrowserVersion requestedPlatform, int data)
{
//InitialiseDriver(dataDrivenData.RequestedPlatform);
InitialiseDriver(requestedPlatform);

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

//guineaPigPage.TypeField(SauceryDriver(), "comments", dataDrivenData.Data.ToString());
guineaPigPage.TypeField(SauceryDriver(), "comments", data.ToString());
}

public IEnumerable<(BrowserVersion, int)> AllCombinations() =>
from browserVersion
in SauceryTestData.Items
from data in new[] { 4, 5 }
select (browserVersion, data);

//public static List<Func<DataDrivenData>> AllCombinations()
//{
// var allPlatforms = RequestedPlatformData.AllPlatforms;

// return GetAllCombinationsAsFunc([4, 5])
// .ConvertAll<Func<DataDrivenData>>(func => () =>
// {
// var array = func();
// var requestedPlatform = (BrowserVersion)array[0];
// var data = (int)array[1];

// return new DataDrivenData
// {
// RequestedPlatform = requestedPlatform,
// Data = data
// };
// });
//}
}

/*
Expand Down
21 changes: 0 additions & 21 deletions Merlin.TUnit/RequestedPlatformData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Saucery.Core.OnDemand;
using Saucery.Core.OnDemand.Base;
using Saucery.Core.Util;
using System.Collections;

namespace Merlin.TUnit;

Expand Down Expand Up @@ -38,26 +37,6 @@ static RequestedPlatformData()
}

public static List<Func<BrowserVersion>> AllPlatforms() => GetAllPlatformsAsFunc();
public static List<BrowserVersion> AllPlatformsAsList() => Items.ToList();

public static List<Func<DataDrivenData>> AllCombinations(object[] data)
{
List<Func<DataDrivenData>> dataDrivenFuncs = [];

foreach (var platform in AllPlatforms())
{
foreach (var obj in data)
{
dataDrivenFuncs.Add(() => new DataDrivenData
{
Data = (int)obj,
RequestedPlatform = platform()
});
}
}

return dataDrivenFuncs;
}
}
/*
* Copyright Andrew Gray, SauceForge
Expand Down

0 comments on commit 12d8ef4

Please sign in to comment.