diff --git a/src/TestApp/shared/SanityTests.cs b/src/TestApp/shared/SanityTests.cs index c2b0039..1ddf6dc 100644 --- a/src/TestApp/shared/SanityTests.cs +++ b/src/TestApp/shared/SanityTests.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -44,6 +45,28 @@ public async Task When_Test_ContentHelper() [DataRow("goodbye", DisplayName = "goodbye test")] public void Is_Sane_With_Cases(string text) { +#pragma warning disable CA1861 // Prefer static readonly + Assert.IsTrue(new[] { "hello", "goodbye" }.Contains(text)); + } + + [TestMethod] + [DynamicData(nameof(DynamicData), DynamicDataSourceType.Property)] + [DynamicData(nameof(GetDynamicData), DynamicDataSourceType.Method)] + public void Is_Sane_With_DynamicData(string text) + { + Assert.IsTrue(new[] { "hello", "goodbye" }.Contains(text)); + } + + public static IEnumerable DynamicData { get; } = new[] + { + new object[] { "hello" }, + new object[] { "goodbye" }, + }; + + public static IEnumerable GetDynamicData() + { + yield return new object[] { "hello" }; + yield return new object[] { "goodbye" }; } #if DEBUG diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestMethodInfo.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestMethodInfo.cs index 1ddfd29..ff973d7 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestMethodInfo.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestMethodInfo.cs @@ -4,6 +4,7 @@ #if !IS_UNO_RUNTIMETEST_PROJECT #pragma warning disable #endif +#pragma warning disable CA1852 // Make class final : unnecessary breaking change using System; using System.Collections.Generic; @@ -93,15 +94,15 @@ public IEnumerable GetCases(CancellationToken ct) foreach (var testCaseSource in _casesParameters) { // Note: CT is not propagated when using a test data source - foreach (var caseData in testCaseSource.GetData(Method)) - { - var data = testCaseSource - .GetData(Method) - .SelectMany(x => x) - .ToArray(); - - cases.Add(new TestCase { Parameters = data, DisplayName = testCaseSource.GetDisplayName(Method, data) }); - } + var testCases = testCaseSource + .GetData(Method) + .Select(caseData => new TestCase + { + Parameters = caseData, + DisplayName = testCaseSource.GetDisplayName(Method, caseData) + }); + + cases.AddRange(testCases); } if (_injectedPointerTypes.Any())