From efa9106b5296c3c9d1e4cca1d2c44062d6ff99d0 Mon Sep 17 00:00:00 2001 From: Jake Soenneker Date: Mon, 16 Dec 2024 17:44:12 -0600 Subject: [PATCH] xunit v3 --- src/Soenneker.Utils.AutoBogus.csproj | 4 +-- .../AutoFakerTests.cs | 8 +++++ .../AutoGeneratorsFixture.Data.cs | 16 +++++----- .../Benchmarking/BenchmarkTest.cs | 4 +-- .../Benchmarking/Benchmarks/GenerateRunner.cs | 3 +- .../Facts/LocalFactAttribute.cs | 29 ------------------- .../Playground/StructFixture.cs | 1 - .../Soenneker.Utils.AutoBogus.Tests.csproj | 7 ++--- 8 files changed, 24 insertions(+), 48 deletions(-) delete mode 100644 test/Soenneker.Utils.AutoBogus.Tests/Facts/LocalFactAttribute.cs diff --git a/src/Soenneker.Utils.AutoBogus.csproj b/src/Soenneker.Utils.AutoBogus.csproj index 41330ce..d31aad7 100644 --- a/src/Soenneker.Utils.AutoBogus.csproj +++ b/src/Soenneker.Utils.AutoBogus.csproj @@ -42,8 +42,8 @@ - - + + diff --git a/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs b/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs index c96f6f6..1d157c8 100644 --- a/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs +++ b/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs @@ -387,6 +387,14 @@ public void Generate_Action_should_be_null() result.Should().BeNull(); } + [Fact] + public void Generate_ActionString_should_be_null() + { + AutoFaker generator = new(); + var result = generator.Generate>(); + result.Should().BeNull(); + } + [Fact] public void Generate_Func_should_be_null() { diff --git a/test/Soenneker.Utils.AutoBogus.Tests/AutoGeneratorsFixture.Data.cs b/test/Soenneker.Utils.AutoBogus.Tests/AutoGeneratorsFixture.Data.cs index 617bf0d..ad6fa85 100644 --- a/test/Soenneker.Utils.AutoBogus.Tests/AutoGeneratorsFixture.Data.cs +++ b/test/Soenneker.Utils.AutoBogus.Tests/AutoGeneratorsFixture.Data.cs @@ -56,7 +56,7 @@ public static IEnumerable GetGenerateTestCases() yield return [typeof(TypedDataSetWithSelfReferencingTable)]; } - [SkippableTheory] + [Theory] [MemberData(nameof(GetGenerateTestCases))] public void Generate_Should_Return_DataSet(Type dataSetType) { @@ -67,7 +67,7 @@ public void Generate_Should_Return_DataSet(Type dataSetType) bool success = BaseDataSetGenerator.TryCreateGenerator(context, cachedType, out BaseDataSetGenerator? generator); - Skip.IfNot(success, $"couldn't create generator for {dataSetType.Name}"); + // Skip.IfNot(success, $"couldn't create generator for {dataSetType.Name}"); // Act object result = generator.Generate(context); @@ -86,7 +86,7 @@ public void Generate_Should_Return_DataSet(Type dataSetType) } } - [SkippableTheory] + [Theory] [MemberData(nameof(GetGenerateTestCases))] public void Generate_Should_Return_DataSet_With_Specified_DataTable_Row_Counts(Type dataSetType) { @@ -120,7 +120,7 @@ public void Generate_Should_Return_DataSet_With_Specified_DataTable_Row_Counts(T bool success = BaseDataSetGenerator.TryCreateGenerator(context, cachedType, out BaseDataSetGenerator? generator); - Skip.IfNot(success, $"couldn't create generator for {dataSetType.Name}"); + //Skip.IfNot(success, $"couldn't create generator for {dataSetType.Name}"); // Act object result = generator.Generate(context); @@ -223,7 +223,7 @@ public static IEnumerable GetGenerateTestCases() yield return [typeof(TypedDataTable2)]; } - [SkippableTheory] + [Theory] [MemberData(nameof(GetGenerateTestCases))] public void Generate_Should_Return_DataTable(Type dataTableType) { @@ -234,7 +234,7 @@ public void Generate_Should_Return_DataTable(Type dataTableType) bool success = BaseDataTableGenerator.TryCreateGenerator(context, cachedType, out BaseDataTableGenerator? generator); - Skip.IfNot(success, $"couldn't create generator for {dataTableType.Name}"); + //Skip.IfNot(success, $"couldn't create generator for {dataTableType.Name}"); // Act object result = generator.Generate(context); @@ -248,7 +248,7 @@ public void Generate_Should_Return_DataTable(Type dataTableType) dataTable.Rows.Should().NotBeEmpty(); } - [SkippableTheory] + [Theory] [MemberData(nameof(GetGenerateTestCases))] public void Generate_Should_Return_DataTable_With_Specified_Row_Count(Type dataTableType) { @@ -262,7 +262,7 @@ public void Generate_Should_Return_DataTable_With_Specified_Row_Count(Type dataT bool success = BaseDataTableGenerator.TryCreateGenerator(context, cachedType, out BaseDataTableGenerator? generator); - Skip.IfNot(success, $"couldn't create generator for {dataTableType.Name}"); + // Skip.IfNot(success, $"couldn't create generator for {dataTableType.Name}"); // Act object result = generator.Generate(context); diff --git a/test/Soenneker.Utils.AutoBogus.Tests/Benchmarking/BenchmarkTest.cs b/test/Soenneker.Utils.AutoBogus.Tests/Benchmarking/BenchmarkTest.cs index 051f7ca..96175f7 100644 --- a/test/Soenneker.Utils.AutoBogus.Tests/Benchmarking/BenchmarkTest.cs +++ b/test/Soenneker.Utils.AutoBogus.Tests/Benchmarking/BenchmarkTest.cs @@ -2,11 +2,11 @@ using BenchmarkDotNet.Columns; using BenchmarkDotNet.Configs; using BenchmarkDotNet.Reports; -using Xunit.Abstractions; +using Xunit; namespace Soenneker.Utils.AutoBogus.Tests.Benchmarking; -public abstract class BenchmarkTest +public abstract class BenchmarkTest { protected ManualConfig DefaultConf { get; } diff --git a/test/Soenneker.Utils.AutoBogus.Tests/Benchmarking/Benchmarks/GenerateRunner.cs b/test/Soenneker.Utils.AutoBogus.Tests/Benchmarking/Benchmarks/GenerateRunner.cs index 0e61af9..93fac3e 100644 --- a/test/Soenneker.Utils.AutoBogus.Tests/Benchmarking/Benchmarks/GenerateRunner.cs +++ b/test/Soenneker.Utils.AutoBogus.Tests/Benchmarking/Benchmarks/GenerateRunner.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; using BenchmarkDotNet.Reports; using BenchmarkDotNet.Running; -using Soenneker.Utils.AutoBogus.Tests.Facts; +using Soenneker.Facts.Local; using Xunit; -using Xunit.Abstractions; namespace Soenneker.Utils.AutoBogus.Tests.Benchmarking.Benchmarks; diff --git a/test/Soenneker.Utils.AutoBogus.Tests/Facts/LocalFactAttribute.cs b/test/Soenneker.Utils.AutoBogus.Tests/Facts/LocalFactAttribute.cs deleted file mode 100644 index d7d8c67..0000000 --- a/test/Soenneker.Utils.AutoBogus.Tests/Facts/LocalFactAttribute.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Soenneker.Utils.AutoBogus.Tests.Utils; -using Xunit; - -namespace Soenneker.Utils.AutoBogus.Tests.Facts; - -/// -/// An xUnit Fact attribute derivation that when used to decorate a method it skips the test if used within a pipeline -/// Replace with [Fact] if you wish to run the test in all environments -/// -internal class LocalFactAttribute : FactAttribute -{ - private const string _defaultSkip = "LocalFact"; - - public string? Reason { get; set; } - - public override string? Skip - { - get - { - if (!EnvironmentUtil.IsPipeline) - return null; - - if (Reason != null) - return $"{_defaultSkip}:{Reason}"; - - return _defaultSkip; - } - } -} \ No newline at end of file diff --git a/test/Soenneker.Utils.AutoBogus.Tests/Playground/StructFixture.cs b/test/Soenneker.Utils.AutoBogus.Tests/Playground/StructFixture.cs index 456fa86..ddc36b4 100644 --- a/test/Soenneker.Utils.AutoBogus.Tests/Playground/StructFixture.cs +++ b/test/Soenneker.Utils.AutoBogus.Tests/Playground/StructFixture.cs @@ -3,7 +3,6 @@ using Soenneker.Utils.AutoBogus.Context; using Soenneker.Utils.AutoBogus.Generators; using Xunit; -using Xunit.Abstractions; namespace Soenneker.Utils.AutoBogus.Tests.Playground; diff --git a/test/Soenneker.Utils.AutoBogus.Tests/Soenneker.Utils.AutoBogus.Tests.csproj b/test/Soenneker.Utils.AutoBogus.Tests/Soenneker.Utils.AutoBogus.Tests.csproj index bba8cc1..03f8847 100644 --- a/test/Soenneker.Utils.AutoBogus.Tests/Soenneker.Utils.AutoBogus.Tests.csproj +++ b/test/Soenneker.Utils.AutoBogus.Tests/Soenneker.Utils.AutoBogus.Tests.csproj @@ -20,9 +20,8 @@ - - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -31,7 +30,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - +