diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index ffd8ca4840..5ff8e57ba2 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -57,6 +57,9 @@ jobs: if: matrix.os == 'ubuntu-latest' uses: docker/setup-docker-action@v4.3.0 + - name: Install PlaywrightDependencies + run: npx playwright install-deps + - name: Build run: dotnet build -c Release diff --git a/TUnit.Assertions.FSharp/Extensions.fs b/TUnit.Assertions.FSharp/Extensions.fs index f5ad56e1c4..35cc98c226 100644 --- a/TUnit.Assertions.FSharp/Extensions.fs +++ b/TUnit.Assertions.FSharp/Extensions.fs @@ -1,7 +1,7 @@ namespace TUnit.Assertions.FSharp open TUnit.Assertions.AssertionBuilders -open TUnit.Assertions.AssertConditions.Throws +open TUnit.Assertions.Extensions module Operations = [] @@ -31,4 +31,4 @@ module Operations = econt ex) | _ -> invalidOp $"Unsupported assertion type: We currently don't support Assertion Type {assertion.GetType()}" - ) \ No newline at end of file + ) diff --git a/TUnit.Assertions.Tests/AssertMultipleTests.cs b/TUnit.Assertions.Tests/AssertMultipleTests.cs index cefbe3ea38..d1868d0fb6 100644 --- a/TUnit.Assertions.Tests/AssertMultipleTests.cs +++ b/TUnit.Assertions.Tests/AssertMultipleTests.cs @@ -1,6 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using TUnit.Assertions.AssertConditions.Throws; - namespace TUnit.Assertions.Tests; [UnconditionalSuppressMessage("Usage", "TUnitAssertions0005:Assert.That(...) should not be used with a constant value")] diff --git a/TUnit.Assertions.Tests/AssertionBuilders/AndAssertionTests.cs b/TUnit.Assertions.Tests/AssertionBuilders/AndAssertionTests.cs index 4cb6a1fb78..a6f015f530 100644 --- a/TUnit.Assertions.Tests/AssertionBuilders/AndAssertionTests.cs +++ b/TUnit.Assertions.Tests/AssertionBuilders/AndAssertionTests.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests.AssertionBuilders; +namespace TUnit.Assertions.Tests.AssertionBuilders; public sealed class AndAssertionTests { diff --git a/TUnit.Assertions.Tests/AssertionBuilders/OrAssertionTests.cs b/TUnit.Assertions.Tests/AssertionBuilders/OrAssertionTests.cs index 67eb148c95..ea4c8a2564 100644 --- a/TUnit.Assertions.Tests/AssertionBuilders/OrAssertionTests.cs +++ b/TUnit.Assertions.Tests/AssertionBuilders/OrAssertionTests.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests.AssertionBuilders; +namespace TUnit.Assertions.Tests.AssertionBuilders; public sealed class OrAssertionTests { diff --git a/TUnit.Assertions.Tests/AssertionGroupTests.cs b/TUnit.Assertions.Tests/AssertionGroupTests.cs index cdd11a906b..15e1642f8e 100644 --- a/TUnit.Assertions.Tests/AssertionGroupTests.cs +++ b/TUnit.Assertions.Tests/AssertionGroupTests.cs @@ -1,5 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; -using TUnit.Assertions.AssertionBuilders.Groups; +using TUnit.Assertions.AssertionBuilders.Groups; namespace TUnit.Assertions.Tests; diff --git a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.ExactlyTests.cs b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.ExactlyTests.cs index b4549b18f4..f25808ec65 100644 --- a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.ExactlyTests.cs +++ b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.ExactlyTests.cs @@ -1,6 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using TUnit.Assertions.AssertConditions.Throws; - namespace TUnit.Assertions.Tests.Assertions.Delegates; public partial class Throws diff --git a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.ExceptionTests.cs b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.ExceptionTests.cs index 85894deef6..640378b685 100644 --- a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.ExceptionTests.cs +++ b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.ExceptionTests.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using TUnit.Assertions.AssertConditions.Throws; namespace TUnit.Assertions.Tests.Assertions.Delegates; diff --git a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.NothingTests.cs b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.NothingTests.cs index 56506764fb..9954450740 100644 --- a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.NothingTests.cs +++ b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.NothingTests.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests.Assertions.Delegates; +namespace TUnit.Assertions.Tests.Assertions.Delegates; public partial class Throws { diff --git a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.OfTypeTests.cs b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.OfTypeTests.cs index d3608db9b3..cf4ddf6a43 100644 --- a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.OfTypeTests.cs +++ b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.OfTypeTests.cs @@ -1,6 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using TUnit.Assertions.AssertConditions.Throws; - namespace TUnit.Assertions.Tests.Assertions.Delegates; public partial class Throws diff --git a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithInnerExceptionTests.cs b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithInnerExceptionTests.cs index a6ea423d5b..954233030f 100644 --- a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithInnerExceptionTests.cs +++ b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithInnerExceptionTests.cs @@ -1,6 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using TUnit.Assertions.AssertConditions.Throws; - namespace TUnit.Assertions.Tests.Assertions.Delegates; public partial class Throws diff --git a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithMessageMatchingTests.cs b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithMessageMatchingTests.cs index 031f6a933c..362d786de6 100644 --- a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithMessageMatchingTests.cs +++ b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithMessageMatchingTests.cs @@ -1,7 +1,5 @@ using System.Diagnostics.CodeAnalysis; using TUnit.Assertions.AssertConditions; -using TUnit.Assertions.AssertConditions.Throws; - namespace TUnit.Assertions.Tests.Assertions.Delegates; public partial class Throws diff --git a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithMessageTests.cs b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithMessageTests.cs index 201095ba27..10c78debf5 100644 --- a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithMessageTests.cs +++ b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithMessageTests.cs @@ -1,6 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using TUnit.Assertions.AssertConditions.Throws; - namespace TUnit.Assertions.Tests.Assertions.Delegates; public partial class Throws diff --git a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithParameterNameTests.cs b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithParameterNameTests.cs index 7086c4daf2..6c5f87968a 100644 --- a/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithParameterNameTests.cs +++ b/TUnit.Assertions.Tests/Assertions/Delegates/Throws.WithParameterNameTests.cs @@ -1,6 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using TUnit.Assertions.AssertConditions.Throws; - namespace TUnit.Assertions.Tests.Assertions.Delegates; public partial class Throws diff --git a/TUnit.Assertions.Tests/Bugs/Tests1600.cs b/TUnit.Assertions.Tests/Bugs/Tests1600.cs index 262e24965f..485ce9e679 100644 --- a/TUnit.Assertions.Tests/Bugs/Tests1600.cs +++ b/TUnit.Assertions.Tests/Bugs/Tests1600.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests.Bugs; +namespace TUnit.Assertions.Tests.Bugs; public class Tests1600 { diff --git a/TUnit.Assertions.Tests/Bugs/Tests1770.cs b/TUnit.Assertions.Tests/Bugs/Tests1770.cs index f9e0785e9a..ff354b6143 100644 --- a/TUnit.Assertions.Tests/Bugs/Tests1770.cs +++ b/TUnit.Assertions.Tests/Bugs/Tests1770.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests.Bugs; +namespace TUnit.Assertions.Tests.Bugs; public class Tests1770 { diff --git a/TUnit.Assertions.Tests/Bugs/Tests1774.cs b/TUnit.Assertions.Tests/Bugs/Tests1774.cs index 882aa84f16..d7c51e253a 100644 --- a/TUnit.Assertions.Tests/Bugs/Tests1774.cs +++ b/TUnit.Assertions.Tests/Bugs/Tests1774.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests.Bugs; +namespace TUnit.Assertions.Tests.Bugs; public class Tests1774 { diff --git a/TUnit.Assertions.Tests/Bugs/Tests2117.cs b/TUnit.Assertions.Tests/Bugs/Tests2117.cs index 47ff022dba..a69058b420 100644 --- a/TUnit.Assertions.Tests/Bugs/Tests2117.cs +++ b/TUnit.Assertions.Tests/Bugs/Tests2117.cs @@ -1,5 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; -using TUnit.Assertions.Enums; +using TUnit.Assertions.Enums; namespace TUnit.Assertions.Tests.Bugs; diff --git a/TUnit.Assertions.Tests/Bugs/Tests2129.cs b/TUnit.Assertions.Tests/Bugs/Tests2129.cs index 699b05cd0e..faf66a1d0c 100644 --- a/TUnit.Assertions.Tests/Bugs/Tests2129.cs +++ b/TUnit.Assertions.Tests/Bugs/Tests2129.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests.Bugs; +namespace TUnit.Assertions.Tests.Bugs; public class Tests2129 { diff --git a/TUnit.Assertions.Tests/Bugs/Tests2145.cs b/TUnit.Assertions.Tests/Bugs/Tests2145.cs index 8d7d41c363..6e3c22623a 100644 --- a/TUnit.Assertions.Tests/Bugs/Tests2145.cs +++ b/TUnit.Assertions.Tests/Bugs/Tests2145.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests.Bugs; +namespace TUnit.Assertions.Tests.Bugs; public class Tests2145 { diff --git a/TUnit.Assertions.Tests/EnumTests.cs b/TUnit.Assertions.Tests/EnumTests.cs index cfdaf6384f..5596a044aa 100644 --- a/TUnit.Assertions.Tests/EnumTests.cs +++ b/TUnit.Assertions.Tests/EnumTests.cs @@ -1,5 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; -using TUnit.Assertions.Assertions.Enums; +using TUnit.Assertions.Assertions.Enums; namespace TUnit.Assertions.Tests; diff --git a/TUnit.Assertions.Tests/EnumerableTests.cs b/TUnit.Assertions.Tests/EnumerableTests.cs index 9c1032141b..89e1590b6f 100644 --- a/TUnit.Assertions.Tests/EnumerableTests.cs +++ b/TUnit.Assertions.Tests/EnumerableTests.cs @@ -1,6 +1,4 @@ using System.Collections; -using TUnit.Assertions.AssertConditions.Throws; - namespace TUnit.Assertions.Tests; public class EnumerableTests diff --git a/TUnit.Assertions.Tests/ExecutionTimeTests.cs b/TUnit.Assertions.Tests/ExecutionTimeTests.cs index 9f16b69be4..55dd613273 100644 --- a/TUnit.Assertions.Tests/ExecutionTimeTests.cs +++ b/TUnit.Assertions.Tests/ExecutionTimeTests.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using TUnit.Assertions.AssertConditions; -using TUnit.Assertions.AssertConditions.Throws; using TUnit.Assertions.Assertions.Delegates; namespace TUnit.Assertions.Tests; diff --git a/TUnit.Assertions.Tests/FailTests.cs b/TUnit.Assertions.Tests/FailTests.cs index 23fe74acd1..bbb6b982aa 100644 --- a/TUnit.Assertions.Tests/FailTests.cs +++ b/TUnit.Assertions.Tests/FailTests.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests; +namespace TUnit.Assertions.Tests; public class FailTests { diff --git a/TUnit.Assertions.Tests/Helpers/StringDifferenceTests.cs b/TUnit.Assertions.Tests/Helpers/StringDifferenceTests.cs index 336d19db9a..7b5c6862f2 100644 --- a/TUnit.Assertions.Tests/Helpers/StringDifferenceTests.cs +++ b/TUnit.Assertions.Tests/Helpers/StringDifferenceTests.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests.Helpers; +namespace TUnit.Assertions.Tests.Helpers; public class StringDifferenceTests { diff --git a/TUnit.Assertions.Tests/Old/DefaultAssertionTests.cs b/TUnit.Assertions.Tests/Old/DefaultAssertionTests.cs index 9f0a5e002d..3182591fb9 100644 --- a/TUnit.Assertions.Tests/Old/DefaultAssertionTests.cs +++ b/TUnit.Assertions.Tests/Old/DefaultAssertionTests.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests.Old; +namespace TUnit.Assertions.Tests.Old; public class DefaultAssertionTests { diff --git a/TUnit.Assertions.Tests/Old/EqualsAssertionTests.cs b/TUnit.Assertions.Tests/Old/EqualsAssertionTests.cs index 3fff296d21..37183b8a4d 100644 --- a/TUnit.Assertions.Tests/Old/EqualsAssertionTests.cs +++ b/TUnit.Assertions.Tests/Old/EqualsAssertionTests.cs @@ -1,5 +1,3 @@ -using TUnit.Assertions.AssertConditions.Throws; - namespace TUnit.Assertions.Tests.Old; public class EqualsAssertionTests diff --git a/TUnit.Assertions.Tests/Old/ExceptionAssertionTests.cs b/TUnit.Assertions.Tests/Old/ExceptionAssertionTests.cs index 66dc9f7cd2..28326427c3 100644 --- a/TUnit.Assertions.Tests/Old/ExceptionAssertionTests.cs +++ b/TUnit.Assertions.Tests/Old/ExceptionAssertionTests.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests.Old; +namespace TUnit.Assertions.Tests.Old; public class ExceptionAssertionTests { diff --git a/TUnit.Assertions.Tests/SatisfiesTests.cs b/TUnit.Assertions.Tests/SatisfiesTests.cs index 24ec294f00..3bf3f85c92 100644 --- a/TUnit.Assertions.Tests/SatisfiesTests.cs +++ b/TUnit.Assertions.Tests/SatisfiesTests.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests; +namespace TUnit.Assertions.Tests; public class SatisfiesTests { diff --git a/TUnit.Assertions.Tests/SkipTests.cs b/TUnit.Assertions.Tests/SkipTests.cs index 345f5d91cc..abc33773a8 100644 --- a/TUnit.Assertions.Tests/SkipTests.cs +++ b/TUnit.Assertions.Tests/SkipTests.cs @@ -1,5 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; -using TUnit.Core.Exceptions; +using TUnit.Core.Exceptions; namespace TUnit.Assertions.Tests; diff --git a/TUnit.Assertions.Tests/ThrowInDelegateValueAssertionTests.cs b/TUnit.Assertions.Tests/ThrowInDelegateValueAssertionTests.cs index 8145b4b321..97668c73dd 100644 --- a/TUnit.Assertions.Tests/ThrowInDelegateValueAssertionTests.cs +++ b/TUnit.Assertions.Tests/ThrowInDelegateValueAssertionTests.cs @@ -1,6 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; - -namespace TUnit.Assertions.Tests; +namespace TUnit.Assertions.Tests; public class ThrowInDelegateValueAssertionTests { diff --git a/TUnit.Assertions/Assert.cs b/TUnit.Assertions/Assert.cs index 2c6f020fa6..5ead56c015 100644 --- a/TUnit.Assertions/Assert.cs +++ b/TUnit.Assertions/Assert.cs @@ -1,7 +1,6 @@ using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; -using TUnit.Assertions.AssertConditions.Throws; using TUnit.Assertions.AssertionBuilders; using TUnit.Assertions.Exceptions; using TUnit.Assertions.Extensions; diff --git a/TUnit.Assertions/Assertions/Throws/ThrowsException.cs b/TUnit.Assertions/Assertions/Throws/ThrowsException.cs index ec4582188a..25d53b7a33 100644 --- a/TUnit.Assertions/Assertions/Throws/ThrowsException.cs +++ b/TUnit.Assertions/Assertions/Throws/ThrowsException.cs @@ -1,10 +1,11 @@ using System.Runtime.CompilerServices; +using TUnit.Assertions.AssertConditions; using TUnit.Assertions.AssertConditions.Interfaces; using TUnit.Assertions.AssertConditions.Operators; +using TUnit.Assertions.AssertConditions.Throws; using TUnit.Assertions.AssertionBuilders; -using TUnit.Assertions.Extensions; -namespace TUnit.Assertions.AssertConditions.Throws; +namespace TUnit.Assertions.Extensions; public class ThrowsException where TException : Exception { diff --git a/TUnit.Assertions/Assertions/Throws/ThrowsExtensions.cs b/TUnit.Assertions/Assertions/Throws/ThrowsExtensions.cs index c6eb2851e6..5b7c2d1dae 100644 --- a/TUnit.Assertions/Assertions/Throws/ThrowsExtensions.cs +++ b/TUnit.Assertions/Assertions/Throws/ThrowsExtensions.cs @@ -1,10 +1,10 @@ using System.Runtime.CompilerServices; using TUnit.Assertions.AssertConditions.Interfaces; using TUnit.Assertions.AssertionBuilders; -using TUnit.Assertions.Assertions.Throws; +using TUnit.Assertions.AssertConditions.Throws; using TUnit.Assertions.Extensions; -namespace TUnit.Assertions.AssertConditions.Throws; +namespace TUnit.Assertions.Extensions; public static class ThrowsExtensions { diff --git a/TUnit.Assertions/Assertions/Throws/ThrowsWithinAssertCondition.cs b/TUnit.Assertions/Assertions/Throws/ThrowsWithinAssertCondition.cs index df8c956f6a..82c98589ae 100644 --- a/TUnit.Assertions/Assertions/Throws/ThrowsWithinAssertCondition.cs +++ b/TUnit.Assertions/Assertions/Throws/ThrowsWithinAssertCondition.cs @@ -3,7 +3,7 @@ using TUnit.Assertions.Extensions; using TUnit.Assertions.Helpers; -namespace TUnit.Assertions.Assertions.Throws; +namespace TUnit.Assertions.AssertConditions.Throws; public class ThrowsWithinAssertCondition(TimeSpan timeSpan) : DelegateAssertCondition where TExpectedException : Exception diff --git a/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs b/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs index d74b3a0d3b..95f70de0f2 100644 --- a/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs +++ b/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs @@ -252,7 +252,7 @@ private static void GenerateTestMetadata(CodeWriter writer, Compilation compilat if (hasTypedDataSource || hasGenerateGenericTest || testMethod.IsGenericMethod || hasClassArguments || hasTypedDataSourceForGenericType || hasMethodArgumentsForGenericType || hasMethodDataSourceForGenericType) { // Use concrete types approach for AOT compatibility - // For generic methods and classes with Arguments attributes, we always use this approach + // For generic methods and classes with Arguments attributes, we always use this approach GenerateGenericTestWithConcreteTypes(writer, compilation, testMethod, className, combinationGuid); } else @@ -497,119 +497,6 @@ private static void GenerateTestMetadataInstance(CodeWriter writer, Compilation writer.AppendLine("tests.Add(metadata);"); } - private static void GenerateAttributeFactoryWithFilteredClassAttributes(CodeWriter writer, Compilation compilation, TestMethodMetadata testMethod, List filteredClassAttributes) - { - writer.AppendLine("AttributeFactory = () =>"); - writer.AppendLine("["); - writer.Indent(); - - var attributes = testMethod.MethodSymbol.GetAttributes() - .Concat(filteredClassAttributes) - .Concat(testMethod.TypeSymbol.ContainingAssembly.GetAttributes()) - .ToImmutableArray(); - - AttributeWriter.WriteAttributes(writer, compilation, attributes); - - writer.Unindent(); - writer.AppendLine("],"); - } - - private static void GenerateMetadataWithFilteredClassAttributes(CodeWriter writer, Compilation compilation, TestMethodMetadata testMethod, List filteredClassAttributes) - { - var methodSymbol = testMethod.MethodSymbol; - var typeSymbol = testMethod.TypeSymbol; - - writer.AppendLine("TimeoutMs = null,"); - writer.AppendLine("RetryCount = 0,"); - writer.AppendLine("RepeatCount = 0,"); - writer.AppendLine("CanRunInParallel = true,"); - - // Generate dependencies - GenerateDependencies(writer, compilation, methodSymbol); - - // Generate attribute factory with filtered class attributes - GenerateAttributeFactoryWithFilteredClassAttributes(writer, compilation, testMethod, filteredClassAttributes); - - // Collect data sources from method - var methodDataSources = methodSymbol.GetAttributes() - .Where(a => DataSourceAttributeHelper.IsDataSourceAttribute(a.AttributeClass) && - a.AttributeClass?.Name != "ArgumentsAttribute") - .ToList(); - - // Filter class data sources to only include the specific Arguments attribute - var classDataSources = filteredClassAttributes - .Where(a => DataSourceAttributeHelper.IsDataSourceAttribute(a.AttributeClass)) - .ToList(); - - // Generate method data sources - writer.AppendLine("DataSources = new global::TUnit.Core.IDataSourceAttribute[]"); - writer.AppendLine("{"); - writer.Indent(); - - foreach (var attr in methodDataSources) - { - GenerateDataSourceAttribute(writer, attr, methodSymbol, typeSymbol); - } - - writer.Unindent(); - writer.AppendLine("},"); - - // Generate class data sources - writer.AppendLine("ClassDataSources = new global::TUnit.Core.IDataSourceAttribute[]"); - writer.AppendLine("{"); - writer.Indent(); - - foreach (var attr in classDataSources) - { - GenerateDataSourceAttribute(writer, attr, methodSymbol, typeSymbol); - } - - writer.Unindent(); - writer.AppendLine("},"); - - // Generate property data sources - GeneratePropertyDataSources(writer, compilation, testMethod); - - // Generate property injections - GeneratePropertyInjections(writer, typeSymbol, typeSymbol.GloballyQualified()); - - // Parameter types - writer.AppendLine("ParameterTypes = new global::System.Type[]"); - writer.AppendLine("{"); - writer.Indent(); - foreach (var param in methodSymbol.Parameters) - { - var paramType = param.Type; - if (IsGenericTypeParameter(paramType) || ContainsGenericTypeParameter(paramType)) - { - // Use object as placeholder for generic type parameters - writer.AppendLine("typeof(global::System.Object),"); - } - else - { - writer.AppendLine($"typeof({paramType.GloballyQualified()}),"); - } - } - writer.Unindent(); - writer.AppendLine("},"); - - // String parameter types - writer.AppendLine("TestMethodParameterTypes = new string[]"); - writer.AppendLine("{"); - writer.Indent(); - foreach (var param in methodSymbol.Parameters) - { - var paramType = param.Type.GloballyQualified(); - writer.AppendLine($"\"{paramType}\","); - } - writer.Unindent(); - writer.AppendLine("},"); - - // Method metadata - writer.Append("MethodMetadata = "); - SourceInformationWriter.GenerateMethodInformation(writer, compilation, testMethod.TypeSymbol, testMethod.MethodSymbol, null, ','); - } - private static void GenerateMetadata(CodeWriter writer, Compilation compilation, TestMethodMetadata testMethod) { var methodSymbol = testMethod.MethodSymbol; @@ -893,7 +780,7 @@ private static void GenerateMethodDataSourceAttribute(CodeWriter writer, Attribu writer.AppendLine("// Error: No method name in MethodDataSourceAttribute"); return; } - + if (targetType == null) { writer.AppendLine("// Error: No target type for MethodDataSourceAttribute"); @@ -2472,7 +2359,7 @@ private static void GenerateGenericTestWithConcreteTypes( { // Handle class-only or method-only Arguments attributes var allArgumentsAttributes = new List(); - + // For generic classes with non-generic methods, don't include method Arguments here // They will be processed separately with InferClassTypesFromMethodArguments if (!(testMethod.IsGenericType && !testMethod.IsGenericMethod)) @@ -2550,10 +2437,10 @@ private static void GenerateGenericTestWithConcreteTypes( // Validate class type constraints bool constraintsValid = ValidateClassTypeConstraints(testMethod.TypeSymbol, inferredTypes); - + // TODO: Fix ValidateClassTypeConstraints method - temporarily skip validation constraintsValid = true; - + if (!constraintsValid) continue; @@ -2808,7 +2695,7 @@ private static void GenerateGenericTestWithConcreteTypes( // Also get class-level data source generators for non-generic classes var nonGenericClassDataSourceGenerators = testMethod.TypeSymbol.GetAttributes() - .Where(a => DataSourceAttributeHelper.IsDataSourceAttribute(a.AttributeClass) && + .Where(a => DataSourceAttributeHelper.IsDataSourceAttribute(a.AttributeClass) && a.AttributeClass?.Name != "ArgumentsAttribute") .ToList(); @@ -2864,7 +2751,7 @@ private static void GenerateGenericTestWithConcreteTypes( var generateGenericTestAttributes = testMethod.MethodAttributes .Where(a => a.AttributeClass?.Name == "GenerateGenericTestAttribute") .ToList(); - + // For generic classes, also check class-level GenerateGenericTest attributes if (testMethod.IsGenericType) { @@ -3020,7 +2907,7 @@ private static bool ValidateClassTypeConstraints(INamedTypeSymbol classSymbol, I { // This is a class type parameter var paramName = typeParam.Name; - + // The argument value's type tells us what the generic type should be ITypeSymbol? argType = null; @@ -3371,7 +3258,7 @@ private static void MapGenericTypeArguments(ITypeSymbol paramType, ITypeSymbol a else if (!method.IsGenericMethod && method.ContainingType.IsGenericType) { var classTypeParams = method.ContainingType.TypeParameters; - + // Single type parameter class if (classTypeParams.Length == 1 && typeArgs.Length >= 1) { @@ -3397,7 +3284,7 @@ private static void MapGenericTypeArguments(ITypeSymbol paramType, ITypeSymbol a else if (method.IsGenericMethod && method.ContainingType.IsGenericType) { var totalGenericParams = method.TypeParameters.Length + method.ContainingType.TypeParameters.Length; - + // Check if the data source provides types for all parameters if (typeArgs.Length == 1 && typeArgs[0] is INamedTypeSymbol { IsTupleType: true } tupleType) { @@ -3406,7 +3293,7 @@ private static void MapGenericTypeArguments(ITypeSymbol paramType, ITypeSymbol a return tupleType.TupleElements.Select(e => e.Type).ToArray(); } } - + // Direct match for multiple type args if (typeArgs.Length == totalGenericParams) { @@ -3624,7 +3511,7 @@ private static bool ValidateTypeConstraints(IMethodSymbol method, ITypeSymbol[] private static bool ValidateTypeParameterConstraints(IEnumerable typeParams, ITypeSymbol[] typeArguments) { var typeParamsList = typeParams.ToList(); - + for (int i = 0; i < typeParamsList.Count; i++) { var typeParam = typeParamsList[i]; @@ -3781,7 +3668,7 @@ private static void GenerateConcreteTestMetadata( else return arg.Value.ToString(); })); - + writer.AppendLine($"return ({concreteClassName})global::System.Activator.CreateInstance(typeof({concreteClassName}), new object[] {{ {constructorArgs} }})!;"); } else @@ -3915,7 +3802,7 @@ private static void GenerateConcreteMetadataWithFilteredDataSources( // Generate attribute factory with filtered attributes var filteredAttributes = new List(); - + // Filter method attributes - only filter Arguments attributes when we have a specific one to match foreach (var attr in methodSymbol.GetAttributes()) { @@ -3934,7 +3821,7 @@ private static void GenerateConcreteMetadataWithFilteredDataSources( filteredAttributes.Add(attr); } } - + // Add all class and assembly attributes (they don't have Arguments attributes) filteredAttributes.AddRange(testMethod.TypeSymbol.GetAttributesIncludingBaseTypes()); filteredAttributes.AddRange(testMethod.TypeSymbol.ContainingAssembly.GetAttributes()); @@ -4093,15 +3980,15 @@ private static bool AreSameAttribute(AttributeData a1, AttributeData a2) { // Look for IInfersType in the attribute's interfaces var infersTypeInterface = attr.AttributeClass.AllInterfaces - .FirstOrDefault(i => ((ISymbol)i).GloballyQualifiedNonGeneric() == "global::TUnit.Core.Interfaces.IInfersType" && - i.IsGenericType && + .FirstOrDefault(i => ((ISymbol)i).GloballyQualifiedNonGeneric() == "global::TUnit.Core.Interfaces.IInfersType" && + i.IsGenericType && i.TypeArguments.Length == 1); - + if (infersTypeInterface != null) { // Get the type argument from IInfersType var inferredType = infersTypeInterface.TypeArguments[0]; - + // Map this to the method's type parameter inferredTypes[typeParam.Name] = inferredType; break; @@ -4148,10 +4035,10 @@ private static bool AreSameAttribute(AttributeData a1, AttributeData a2) { // Look for IInfersType in the attribute's interfaces var infersTypeInterface = attr.AttributeClass.AllInterfaces - .FirstOrDefault(i => ((ISymbol)i).GloballyQualifiedNonGeneric() == "global::TUnit.Core.Interfaces.IInfersType" && - i.IsGenericType && + .FirstOrDefault(i => ((ISymbol)i).GloballyQualifiedNonGeneric() == "global::TUnit.Core.Interfaces.IInfersType" && + i.IsGenericType && i.TypeArguments.Length == 1); - + if (infersTypeInterface != null) { // Get the type argument from IInfersType @@ -4159,7 +4046,7 @@ private static bool AreSameAttribute(AttributeData a1, AttributeData a2) inferredTypes[typeParam.Name] = inferredType; break; } - + // Fall back to checking if it's a data source attribute with type info if (attr.AttributeClass.IsOrInherits("global::TUnit.Core.AsyncDataSourceGeneratorAttribute")) { @@ -4203,7 +4090,7 @@ private static bool AreSameAttribute(AttributeData a1, AttributeData a2) { var name = current.Name; var namespaceName = current.ContainingNamespace?.ToDisplayString(); - + // Check for exact match of the typed base classes if ((name == "DataSourceGeneratorAttribute" || name == "AsyncDataSourceGeneratorAttribute") && namespaceName?.Contains("TUnit.Core") == true) @@ -4362,8 +4249,8 @@ private static void GenerateConcreteTestMetadataForNonGeneric( { // For classes with constructor parameters, check if we have Arguments attribute var isArgumentsAttribute = classDataSourceAttribute?.AttributeClass?.Name == "ArgumentsAttribute"; - - if (isArgumentsAttribute && classDataSourceAttribute != null && + + if (isArgumentsAttribute && classDataSourceAttribute != null && classDataSourceAttribute.ConstructorArguments.Length > 0 && classDataSourceAttribute.ConstructorArguments[0].Kind == TypedConstantKind.Array) { diff --git a/TUnit.Core.SourceGenerator/Utilities/MetadataGenerationHelper.cs b/TUnit.Core.SourceGenerator/Utilities/MetadataGenerationHelper.cs index 6479a8e6a6..89f7a08e48 100644 --- a/TUnit.Core.SourceGenerator/Utilities/MetadataGenerationHelper.cs +++ b/TUnit.Core.SourceGenerator/Utilities/MetadataGenerationHelper.cs @@ -10,62 +10,6 @@ namespace TUnit.Core.SourceGenerator.Utilities; /// internal static class MetadataGenerationHelper { - /// - /// Generates code for creating a TestMetadata instance - /// - public static void GenerateTestMetadata(CodeWriter writer, string metadataTypeParameter, TestMetadataGenerationArgs args) - { - writer.AppendLine($"var metadata = new global::TUnit.Core.TestMetadata<{metadataTypeParameter}>"); - writer.AppendLine("{"); - writer.Indent(); - - writer.AppendLine($"TestName = \"{args.TestName}\","); - writer.AppendLine($"TestClassType = {args.TestClassTypeReference},"); - writer.AppendLine($"TestMethodName = \"{args.TestMethodName}\","); - writer.AppendLine($"IsSkipped = {args.IsSkipped.ToString().ToLower()},"); - writer.AppendLine($"SkipReason = {(args.SkipReason != null ? $"\"{args.SkipReason}\"" : "null")},"); - writer.AppendLine($"TimeoutMs = {args.TimeoutMs?.ToString() ?? "null"},"); - writer.AppendLine($"RetryCount = {args.RetryCount},"); - writer.AppendLine($"RepeatCount = {args.RepeatCount},"); - writer.AppendLine($"CanRunInParallel = {args.CanRunInParallel.ToString().ToLower()},"); - writer.AppendLine($"Dependencies = {args.Dependencies ?? "global::System.Array.Empty()"},"); - writer.AppendLine($"DataSources = {args.DataSources ?? "global::System.Array.Empty()"},"); - writer.AppendLine($"ClassDataSources = {args.ClassDataSources ?? "global::System.Array.Empty()"},"); - writer.AppendLine($"PropertyDataSources = {args.PropertyDataSources ?? "global::System.Array.Empty()"},"); - writer.AppendLine($"InstanceFactory = {args.InstanceFactory ?? "null"},"); - writer.AppendLine($"TestInvoker = {args.TestInvoker ?? "null"},"); - writer.AppendLine($"ParameterCount = {args.ParameterCount},"); - writer.AppendLine($"ParameterTypes = {args.ParameterTypes ?? "global::System.Array.Empty()"},"); - writer.AppendLine($"TestMethodParameterTypes = {args.TestMethodParameterTypes ?? "global::System.Array.Empty()"},"); - writer.AppendLine($"Hooks = {args.Hooks ?? "new global::TUnit.Core.TestHooks { BeforeClass = global::System.Array.Empty(), AfterClass = global::System.Array.Empty(), BeforeTest = global::System.Array.Empty(), AfterTest = global::System.Array.Empty() }"},"); - writer.AppendLine($"FilePath = {(args.FilePath != null ? $"@\"{args.FilePath}\"" : "null")},"); - writer.AppendLine($"LineNumber = {args.LineNumber?.ToString() ?? "null"},"); - writer.AppendLine($"MethodMetadata = {args.MethodMetadata},"); - writer.AppendLine($"GenericTypeInfo = {args.GenericTypeInfo ?? "null"},"); - writer.AppendLine($"GenericMethodInfo = {args.GenericMethodInfo ?? "null"},"); - writer.AppendLine($"GenericMethodTypeArguments = {args.GenericMethodTypeArguments ?? "null"},"); - writer.AppendLine($"AttributeFactory = {args.AttributeFactory},"); - writer.AppendLine($"PropertyInjections = {args.PropertyInjections ?? "global::System.Array.Empty()"},"); - writer.AppendLine($"TestSessionId = \"{args.TestSessionId}\","); - - // Additional properties specific to TestMetadata - if (args.CreateInstance != null) - { - writer.AppendLine($"CreateInstance = {args.CreateInstance},"); - } - if (args.InvokeTest != null) - { - writer.AppendLine($"InvokeTest = {args.InvokeTest},"); - } - if (args.InvokeTypedTest != null) - { - writer.AppendLine($"InvokeTypedTest = {args.InvokeTypedTest},"); - } - - writer.Unindent(); - writer.AppendLine("};"); - } - /// /// Generates code for creating a MethodMetadata instance /// @@ -312,33 +256,6 @@ private static string GetPropertyAccessor(INamedTypeSymbol namedTypeSymbol, IPro : $"o => (({safeTypeName})o).{property.Name}"; } - /// - /// Generates an array of ParameterMetadata objects - /// - private static string GenerateParameterMetadataArray(IEnumerable parameters, IMethodSymbol? containingMethod = null) - { - var paramList = parameters.ToList(); - if (!paramList.Any()) - { - return "global::System.Array.Empty()"; - } - - var writer = new CodeWriter("", includeHeader: false); - writer.AppendLine("new global::TUnit.Core.ParameterMetadata[]"); - writer.AppendLine("{"); - writer.Indent(); - - foreach (var param in paramList) - { - writer.AppendLine($"{GenerateParameterMetadata(param, containingMethod)},"); - } - - writer.Unindent(); - writer.Append("}"); - - return writer.ToString(); - } - /// /// Generates an array of ParameterMetadata objects for method parameters with proper reflection info /// @@ -421,59 +338,4 @@ private static string GeneratePropertyMetadataArray(INamedTypeSymbol typeSymbol) return writer.ToString(); } - - /// - /// Generates a string array expression - /// - private static string GenerateStringArray(string[]? values) - { - if (values == null || values.Length == 0) - { - return "global::System.Array.Empty()"; - } - - var items = string.Join(", ", values.Select(v => $"\"{v}\"")); - return $"new string[] {{ {items} }}"; - } -} - -/// -/// Arguments for generating TestMetadata -/// -internal class TestMetadataGenerationArgs -{ - public required string TestName { get; init; } - public required string TestClassTypeReference { get; init; } - public required string TestMethodName { get; init; } - public string[]? Categories { get; init; } - public bool IsSkipped { get; init; } - public string? SkipReason { get; init; } - public int? TimeoutMs { get; init; } - public int RetryCount { get; init; } - public int RepeatCount { get; init; } = 1; - public bool CanRunInParallel { get; init; } = true; - public string? Dependencies { get; init; } - public string? DataSources { get; init; } - public string? ClassDataSources { get; init; } - public string? PropertyDataSources { get; init; } - public string? InstanceFactory { get; init; } - public string? TestInvoker { get; init; } - public int ParameterCount { get; init; } - public string? ParameterTypes { get; init; } - public string? TestMethodParameterTypes { get; init; } - public string? Hooks { get; init; } - public string? FilePath { get; init; } - public int? LineNumber { get; init; } - public required string MethodMetadata { get; init; } - public string? GenericTypeInfo { get; init; } - public string? GenericMethodInfo { get; init; } - public string? GenericMethodTypeArguments { get; init; } - public required string AttributeFactory { get; init; } - public string? PropertyInjections { get; init; } - public required string TestSessionId { get; init; } - - // Additional properties specific to TestMetadata - public string? CreateInstance { get; init; } - public string? InvokeTest { get; init; } - public string? InvokeTypedTest { get; init; } } diff --git a/TUnit.Engine/Services/EventReceiverOrchestrator.cs b/TUnit.Engine/Services/EventReceiverOrchestrator.cs index a5ac456600..358b1327fe 100644 --- a/TUnit.Engine/Services/EventReceiverOrchestrator.cs +++ b/TUnit.Engine/Services/EventReceiverOrchestrator.cs @@ -192,45 +192,6 @@ private async ValueTask InvokeTestSkippedEventReceiversCore(TestContext context, } } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public async ValueTask InvokeTestRegisteredEventReceiversAsync(TestContext context, CancellationToken cancellationToken) - { - if (!_registry.HasTestRegisteredReceivers()) - { - return; - } - - await InvokeTestRegisteredEventReceiversCore(context, cancellationToken); - } - - private async ValueTask InvokeTestRegisteredEventReceiversCore(TestContext context, CancellationToken cancellationToken) - { - var receivers = context.GetEligibleEventObjects() - .OfType() - .OrderBy(r => r.Order) - .ToList(); - - // Filter scoped attributes - var filteredReceivers = ScopedAttributeFilter.FilterScopedAttributes(receivers); - - var registeredContext = new TestRegisteredContext(context) - { - DiscoveredTest = context.InternalDiscoveredTest! - }; - - foreach (var receiver in filteredReceivers) - { - try - { - await receiver.OnTestRegistered(registeredContext); - } - catch (Exception ex) - { - await _logger.LogErrorAsync($"Error in test registered event receiver: {ex.Message}"); - } - } - } - public async ValueTask InvokeTestDiscoveryEventReceiversAsync(TestContext context, DiscoveredTestContext discoveredContext, CancellationToken cancellationToken) { var eventReceivers = context.GetEligibleEventObjects() diff --git a/TUnit.Engine/Services/TestFilterService.cs b/TUnit.Engine/Services/TestFilterService.cs index e464aa64ca..5f4271c4ec 100644 --- a/TUnit.Engine/Services/TestFilterService.cs +++ b/TUnit.Engine/Services/TestFilterService.cs @@ -5,6 +5,7 @@ using TUnit.Core; using TUnit.Core.Interfaces; using TUnit.Core.Logging; +using TUnit.Engine.Extensions; using TUnit.Engine.Logging; namespace TUnit.Engine.Services; @@ -48,20 +49,18 @@ private async Task RegisterTest(AbstractExecutableTest test) test.Context.InternalDiscoveredTest = discoveredTest; - var attributes = test.Context.TestDetails.Attributes; + var eventObjects = test.Context.GetEligibleEventObjects(); - foreach (var attribute in attributes) + foreach (var receiver in eventObjects.OfType()) { - if (attribute is ITestRegisteredEventReceiver receiver) + try { - try - { - await receiver.OnTestRegistered(registeredContext); - } - catch (Exception ex) - { - await logger.LogErrorAsync($"Error in test registered event receiver: {ex.Message}"); - } + await receiver.OnTestRegistered(registeredContext); + } + catch (Exception ex) + { + await logger.LogErrorAsync($"Error in test registered event receiver: {ex.Message}"); + throw; } } @@ -101,8 +100,8 @@ private string BuildPath(AbstractExecutableTest test) var classTypeName = classMetadata.Name; var path = $"/{assemblyName}/{namespaceName}/{classTypeName}/{metadata.TestMethodName}"; - - + + return path; } diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt index 514e9bc173..8fe331196c 100644 --- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt +++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt @@ -22,23 +22,23 @@ namespace where TException : { } public static TException Throws(string parameterName, @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync( type, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) + public static . ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync( type, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(string parameterName, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) + public static . ThrowsAsync(string parameterName, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) where TException : { } - public static ..ThrowsException ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) + public static . ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) where TException : { } - public static ..ThrowsException ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) + public static . ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) where TException : { } } public readonly struct AssertionData : <.AssertionData> @@ -578,36 +578,6 @@ namespace . protected override string GetExpectation() { } protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } } - public class ThrowsException - where TException : - { - public ThrowsException(. delegateAssertionBuilder, ..IDelegateSource source, selector) { } - public ..ValueAnd And { get; } - public ..DelegateOr Or { get; } - public . GetAwaiter() { } - public ..ThrowsException WithInnerException() { } - public ..ThrowsException WithMessage(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } - public ..ThrowsException WithMessageContaining(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } - public ..ThrowsException WithMessageContaining(string expected, stringComparison, [.("expected")] string? doNotPopulateThisValue = null, [.("stringComparison")] string? doNotPopulateThisValue2 = null) { } - public ..ThrowsException WithMessageMatching(. match, [.("match")] string? doNotPopulateThisValue = null) { } - public static . op_Explicit(..ThrowsException throwsException) { } - } - public static class ThrowsExtensions - { - public static ..ThrowsException Throws(this ..IDelegateSource delegateSource, type, [.("type")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException Throws(this ..IDelegateSource delegateSource) - where TException : { } - public static ..ThrowsException ThrowsExactly(this ..IDelegateSource delegateSource) - where TException : { } - public static ..ThrowsException ThrowsException(this ..IDelegateSource delegateSource) { } - public static . ThrowsNothing(this ..IDelegateSource delegateSource) { } - public static . ThrowsNothing(this ..IValueDelegateSource delegateSource) { } - public static ..ThrowsException ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) - where TException : { } - public static ..ThrowsException WithParameterName(this ..ThrowsException throwsException, string expected, [.("expected")] string? doNotPopulateThisValue = null) - where TException : { } - } public class ThrowsNothingAssertCondition : . { public ThrowsNothingAssertCondition() { } @@ -655,6 +625,14 @@ namespace . protected override string GetExpectation() { } protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } } + public class ThrowsWithinAssertCondition : . + where TExpectedException : + { + public ThrowsWithinAssertCondition( timeSpan) { } + public override ? WaitFor { get; } + protected override string GetExpectation() { } + protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } + } } namespace .AssertionBuilders { @@ -1121,17 +1099,6 @@ namespace ..Conditions protected override .<.> GetResult(string? actualValue, string? expectedValue) { } } } -namespace . -{ - public class ThrowsWithinAssertCondition : . - where TExpectedException : - { - public ThrowsWithinAssertCondition( timeSpan) { } - public override ? WaitFor { get; } - protected override string GetExpectation() { } - protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } - } -} namespace .Enums { public enum CollectionOrdering @@ -1555,6 +1522,36 @@ namespace .Extensions public . LessThan(int expected, [.("expected")] string? doNotPopulateThisValue = null) { } public . LessThanOrEqualTo(int expected, [.("expected")] string? doNotPopulateThisValue = null) { } } + public class ThrowsException + where TException : + { + public ThrowsException(. delegateAssertionBuilder, ..IDelegateSource source, selector) { } + public ..ValueAnd And { get; } + public ..DelegateOr Or { get; } + public . GetAwaiter() { } + public . WithInnerException() { } + public . WithMessage(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } + public . WithMessageContaining(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } + public . WithMessageContaining(string expected, stringComparison, [.("expected")] string? doNotPopulateThisValue = null, [.("stringComparison")] string? doNotPopulateThisValue2 = null) { } + public . WithMessageMatching(. match, [.("match")] string? doNotPopulateThisValue = null) { } + public static . op_Explicit(. throwsException) { } + } + public static class ThrowsExtensions + { + public static . Throws(this ..IDelegateSource delegateSource, type, [.("type")] string? doNotPopulateThisValue = null) { } + public static . Throws(this ..IDelegateSource delegateSource) + where TException : { } + public static . ThrowsExactly(this ..IDelegateSource delegateSource) + where TException : { } + public static . ThrowsException(this ..IDelegateSource delegateSource) { } + public static . ThrowsNothing(this ..IDelegateSource delegateSource) { } + public static . ThrowsNothing(this ..IValueDelegateSource delegateSource) { } + public static . ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) { } + public static . ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) + where TException : { } + public static . WithParameterName(this . throwsException, string expected, [.("expected")] string? doNotPopulateThisValue = null) + where TException : { } + } public static class TimeOnlyIsExtensions { public static .<> IsAfter(this ..IValueSource<> valueSource, expected, [.("expected")] string doNotPopulateThisValue = null) { } diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt index 5330ba6c0d..ee46f07930 100644 --- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt +++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt @@ -22,23 +22,23 @@ namespace where TException : { } public static TException Throws(string parameterName, @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync( type, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) + public static . ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync( type, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(string parameterName, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) + public static . ThrowsAsync(string parameterName, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) where TException : { } - public static ..ThrowsException ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) + public static . ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) where TException : { } - public static ..ThrowsException ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) + public static . ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) where TException : { } } public readonly struct AssertionData : <.AssertionData> @@ -578,36 +578,6 @@ namespace . protected override string GetExpectation() { } protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } } - public class ThrowsException - where TException : - { - public ThrowsException(. delegateAssertionBuilder, ..IDelegateSource source, selector) { } - public ..ValueAnd And { get; } - public ..DelegateOr Or { get; } - public . GetAwaiter() { } - public ..ThrowsException WithInnerException() { } - public ..ThrowsException WithMessage(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } - public ..ThrowsException WithMessageContaining(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } - public ..ThrowsException WithMessageContaining(string expected, stringComparison, [.("expected")] string? doNotPopulateThisValue = null, [.("stringComparison")] string? doNotPopulateThisValue2 = null) { } - public ..ThrowsException WithMessageMatching(. match, [.("match")] string? doNotPopulateThisValue = null) { } - public static . op_Explicit(..ThrowsException throwsException) { } - } - public static class ThrowsExtensions - { - public static ..ThrowsException Throws(this ..IDelegateSource delegateSource, type, [.("type")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException Throws(this ..IDelegateSource delegateSource) - where TException : { } - public static ..ThrowsException ThrowsExactly(this ..IDelegateSource delegateSource) - where TException : { } - public static ..ThrowsException ThrowsException(this ..IDelegateSource delegateSource) { } - public static . ThrowsNothing(this ..IDelegateSource delegateSource) { } - public static . ThrowsNothing(this ..IValueDelegateSource delegateSource) { } - public static ..ThrowsException ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) - where TException : { } - public static ..ThrowsException WithParameterName(this ..ThrowsException throwsException, string expected, [.("expected")] string? doNotPopulateThisValue = null) - where TException : { } - } public class ThrowsNothingAssertCondition : . { public ThrowsNothingAssertCondition() { } @@ -655,6 +625,14 @@ namespace . protected override string GetExpectation() { } protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } } + public class ThrowsWithinAssertCondition : . + where TExpectedException : + { + public ThrowsWithinAssertCondition( timeSpan) { } + public override ? WaitFor { get; } + protected override string GetExpectation() { } + protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } + } } namespace .AssertionBuilders { @@ -1121,17 +1099,6 @@ namespace ..Conditions protected override .<.> GetResult(string? actualValue, string? expectedValue) { } } } -namespace . -{ - public class ThrowsWithinAssertCondition : . - where TExpectedException : - { - public ThrowsWithinAssertCondition( timeSpan) { } - public override ? WaitFor { get; } - protected override string GetExpectation() { } - protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } - } -} namespace .Enums { public enum CollectionOrdering @@ -1555,6 +1522,36 @@ namespace .Extensions public . LessThan(int expected, [.("expected")] string? doNotPopulateThisValue = null) { } public . LessThanOrEqualTo(int expected, [.("expected")] string? doNotPopulateThisValue = null) { } } + public class ThrowsException + where TException : + { + public ThrowsException(. delegateAssertionBuilder, ..IDelegateSource source, selector) { } + public ..ValueAnd And { get; } + public ..DelegateOr Or { get; } + public . GetAwaiter() { } + public . WithInnerException() { } + public . WithMessage(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } + public . WithMessageContaining(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } + public . WithMessageContaining(string expected, stringComparison, [.("expected")] string? doNotPopulateThisValue = null, [.("stringComparison")] string? doNotPopulateThisValue2 = null) { } + public . WithMessageMatching(. match, [.("match")] string? doNotPopulateThisValue = null) { } + public static . op_Explicit(. throwsException) { } + } + public static class ThrowsExtensions + { + public static . Throws(this ..IDelegateSource delegateSource, type, [.("type")] string? doNotPopulateThisValue = null) { } + public static . Throws(this ..IDelegateSource delegateSource) + where TException : { } + public static . ThrowsExactly(this ..IDelegateSource delegateSource) + where TException : { } + public static . ThrowsException(this ..IDelegateSource delegateSource) { } + public static . ThrowsNothing(this ..IDelegateSource delegateSource) { } + public static . ThrowsNothing(this ..IValueDelegateSource delegateSource) { } + public static . ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) { } + public static . ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) + where TException : { } + public static . WithParameterName(this . throwsException, string expected, [.("expected")] string? doNotPopulateThisValue = null) + where TException : { } + } public static class TimeOnlyIsExtensions { public static .<> IsAfter(this ..IValueSource<> valueSource, expected, [.("expected")] string doNotPopulateThisValue = null) { } diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt index 4c7f00c89c..2caf76d4cf 100644 --- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt +++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt @@ -1,4 +1,4 @@ -[assembly: .(".NETStandard,Version=v2.0", FrameworkDisplayName=".NET Standard 2.0")] +[assembly: .(".NETStandard,Version=v2.0", FrameworkDisplayName=".NET Standard 2.0")] namespace { public static class Assert @@ -21,23 +21,23 @@ namespace where TException : { } public static TException Throws(string parameterName, @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync( type, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) + public static . ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync( type, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync( type, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null) { } + public static . ThrowsAsync(<.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) + public static . ThrowsAsync(. @delegate, [.("delegate")] string? doNotPopulateThisValue = null) where TException : { } - public static ..ThrowsException ThrowsAsync(string parameterName, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) + public static . ThrowsAsync(string parameterName, <.> @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) where TException : { } - public static ..ThrowsException ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) + public static . ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) where TException : { } - public static ..ThrowsException ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) + public static . ThrowsAsync(string parameterName, . @delegate, [.("delegate")] string? doNotPopulateThisValue = null, [.("parameterName")] string? doNotPopulateThisValue2 = null) where TException : { } } public readonly struct AssertionData : <.AssertionData> @@ -556,36 +556,6 @@ namespace . protected override string GetExpectation() { } protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } } - public class ThrowsException - where TException : - { - public ThrowsException(. delegateAssertionBuilder, ..IDelegateSource source, selector) { } - public ..ValueAnd And { get; } - public ..DelegateOr Or { get; } - public . GetAwaiter() { } - public ..ThrowsException WithInnerException() { } - public ..ThrowsException WithMessage(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } - public ..ThrowsException WithMessageContaining(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } - public ..ThrowsException WithMessageContaining(string expected, stringComparison, [.("expected")] string? doNotPopulateThisValue = null, [.("stringComparison")] string? doNotPopulateThisValue2 = null) { } - public ..ThrowsException WithMessageMatching(. match, [.("match")] string? doNotPopulateThisValue = null) { } - public static . op_Explicit(..ThrowsException throwsException) { } - } - public static class ThrowsExtensions - { - public static ..ThrowsException Throws(this ..IDelegateSource delegateSource, type, [.("type")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException Throws(this ..IDelegateSource delegateSource) - where TException : { } - public static ..ThrowsException ThrowsExactly(this ..IDelegateSource delegateSource) - where TException : { } - public static ..ThrowsException ThrowsException(this ..IDelegateSource delegateSource) { } - public static . ThrowsNothing(this ..IDelegateSource delegateSource) { } - public static . ThrowsNothing(this ..IValueDelegateSource delegateSource) { } - public static ..ThrowsException ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) { } - public static ..ThrowsException ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) - where TException : { } - public static ..ThrowsException WithParameterName(this ..ThrowsException throwsException, string expected, [.("expected")] string? doNotPopulateThisValue = null) - where TException : { } - } public class ThrowsNothingAssertCondition : . { public ThrowsNothingAssertCondition() { } @@ -633,6 +603,14 @@ namespace . protected override string GetExpectation() { } protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } } + public class ThrowsWithinAssertCondition : . + where TExpectedException : + { + public ThrowsWithinAssertCondition( timeSpan) { } + public override ? WaitFor { get; } + protected override string GetExpectation() { } + protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } + } } namespace .AssertionBuilders { @@ -1088,17 +1066,6 @@ namespace ..Conditions protected override .<.> GetResult(string? actualValue, string? expectedValue) { } } } -namespace . -{ - public class ThrowsWithinAssertCondition : . - where TExpectedException : - { - public ThrowsWithinAssertCondition( timeSpan) { } - public override ? WaitFor { get; } - protected override string GetExpectation() { } - protected override .<.> GetResult(TActual? actualValue, ? exception, .AssertionMetadata assertionMetadata) { } - } -} namespace .Enums { public enum CollectionOrdering @@ -1468,6 +1435,36 @@ namespace .Extensions public . LessThan(int expected, [.("expected")] string? doNotPopulateThisValue = null) { } public . LessThanOrEqualTo(int expected, [.("expected")] string? doNotPopulateThisValue = null) { } } + public class ThrowsException + where TException : + { + public ThrowsException(. delegateAssertionBuilder, ..IDelegateSource source, selector) { } + public ..ValueAnd And { get; } + public ..DelegateOr Or { get; } + public . GetAwaiter() { } + public . WithInnerException() { } + public . WithMessage(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } + public . WithMessageContaining(string expected, [.("expected")] string? doNotPopulateThisValue = null) { } + public . WithMessageContaining(string expected, stringComparison, [.("expected")] string? doNotPopulateThisValue = null, [.("stringComparison")] string? doNotPopulateThisValue2 = null) { } + public . WithMessageMatching(. match, [.("match")] string? doNotPopulateThisValue = null) { } + public static . op_Explicit(. throwsException) { } + } + public static class ThrowsExtensions + { + public static . Throws(this ..IDelegateSource delegateSource, type, [.("type")] string? doNotPopulateThisValue = null) { } + public static . Throws(this ..IDelegateSource delegateSource) + where TException : { } + public static . ThrowsExactly(this ..IDelegateSource delegateSource) + where TException : { } + public static . ThrowsException(this ..IDelegateSource delegateSource) { } + public static . ThrowsNothing(this ..IDelegateSource delegateSource) { } + public static . ThrowsNothing(this ..IValueDelegateSource delegateSource) { } + public static . ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) { } + public static . ThrowsWithin(this ..IDelegateSource delegateSource, timeSpan, [.("timeSpan")] string? doNotPopulateThisValue = null) + where TException : { } + public static . WithParameterName(this . throwsException, string expected, [.("expected")] string? doNotPopulateThisValue = null) + where TException : { } + } public static class TimeSpanExtensions { public static Days(this int days) { } diff --git a/TUnit.TestProject/Bugs/1304/Tests.cs b/TUnit.TestProject/Bugs/1304/Tests.cs index d91c97e80e..de888885b5 100644 --- a/TUnit.TestProject/Bugs/1304/Tests.cs +++ b/TUnit.TestProject/Bugs/1304/Tests.cs @@ -1,5 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; -using TUnit.TestProject.Attributes; +using TUnit.TestProject.Attributes; using Vogen; namespace TUnit.TestProject.Bugs._1304; diff --git a/TUnit.TestProject/DependsOnTests2.cs b/TUnit.TestProject/DependsOnTests2.cs index 7a9e9e49c8..c1896f4d8e 100644 --- a/TUnit.TestProject/DependsOnTests2.cs +++ b/TUnit.TestProject/DependsOnTests2.cs @@ -1,5 +1,4 @@ -using TUnit.Assertions.AssertConditions.Throws; -using TUnit.TestProject.Attributes; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; diff --git a/TUnit.TestProject/InitializableTestClassTests.cs b/TUnit.TestProject/InitializableTestClassTests.cs new file mode 100644 index 0000000000..19c4c04cb5 --- /dev/null +++ b/TUnit.TestProject/InitializableTestClassTests.cs @@ -0,0 +1,62 @@ +using TUnit.Core.Interfaces; +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] +public class InitializableTestClassTests : IAsyncInitializer +{ + public Task InitializeAsync() + { + IsInitialized = true; + return Task.CompletedTask; + } + + public bool IsInitialized + { + get; + set; + } + + [Test] + public async Task Basic() + { + await Assert.That(IsInitialized).IsTrue(); + } + + [Test] + [Arguments(1)] + [Arguments(2)] + public async Task Args(int i) + { + await Assert.That(IsInitialized).IsTrue(); + } + + [Test] + [MethodDataSource(nameof(Data))] + public async Task Method(int i) + { + await Assert.That(IsInitialized).IsTrue(); + } + + [Test] + [DataGenerator] + public async Task DataGenerator(int i) + { + await Assert.That(IsInitialized).IsTrue(); + } + + public static int Data() + { + return 3; + } + + public class DataGeneratorAttribute : DataSourceGeneratorAttribute + { + protected override IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata) + { + yield return () => 4; + yield return () => 5; + } + } +} diff --git a/TUnit.TestProject/Tests.cs b/TUnit.TestProject/Tests.cs index 8996419374..7ee28ca7d5 100644 --- a/TUnit.TestProject/Tests.cs +++ b/TUnit.TestProject/Tests.cs @@ -1,6 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using TUnit.Assertions.AssertConditions.Throws; - namespace TUnit.TestProject; [UnconditionalSuppressMessage("Usage", "TUnitAssertions0005:Assert.That(...) should not be used with a constant value")] diff --git a/TUnit.UnitTests/ServiceProviderInfrastructureTests.cs b/TUnit.UnitTests/ServiceProviderInfrastructureTests.cs index b3a4a1b57d..34c14b5d03 100644 --- a/TUnit.UnitTests/ServiceProviderInfrastructureTests.cs +++ b/TUnit.UnitTests/ServiceProviderInfrastructureTests.cs @@ -1,4 +1,3 @@ -using TUnit.Assertions.AssertConditions.Throws; using TUnit.Core.Services; namespace TUnit.UnitTests; diff --git a/test-single-file-fix.ps1 b/test-single-file-fix.ps1 deleted file mode 100644 index 70e56d3058..0000000000 --- a/test-single-file-fix.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env pwsh - -Write-Host "Testing single file mode fixes for data source discovery" -ForegroundColor Cyan - -# Build the test project -Write-Host "`nBuilding TUnit.TestProject..." -ForegroundColor Yellow -dotnet build TUnit.TestProject -c Release - -# Run the specific test in different modes -Write-Host "`nRunning ClassDataSourceWithMethodDataSourceTests in normal mode..." -ForegroundColor Yellow -dotnet run --project TUnit.TestProject -c Release --no-build -- --treenode-filter "/*/*/ClassDataSourceWithMethodDataSourceTests/*" - -Write-Host "`nRunning ClassDataSourceWithMethodDataSourceTests in reflection mode..." -ForegroundColor Yellow -dotnet run --project TUnit.TestProject -c Release --no-build -- --treenode-filter "/*/*/ClassDataSourceWithMethodDataSourceTests/*" --reflection - -Write-Host "`nRunning DiagnosticClassDataSourceTests in normal mode..." -ForegroundColor Yellow -dotnet run --project TUnit.TestProject -c Release --no-build -- --treenode-filter "/*/*/DiagnosticClassDataSourceTests/*" - -Write-Host "`nRunning DiagnosticClassDataSourceTests in reflection mode..." -ForegroundColor Yellow -dotnet run --project TUnit.TestProject -c Release --no-build -- --treenode-filter "/*/*/DiagnosticClassDataSourceTests/*" --reflection - -Write-Host "`nTo test single file mode, publish as single file and run:" -ForegroundColor Green -Write-Host "dotnet publish TUnit.TestProject -c Release -r win-x64 --self-contained -p:PublishSingleFile=true" -ForegroundColor Gray -Write-Host "Then run the executable with: --treenode-filter `"/*/*/ClassDataSourceWithMethodDataSourceTests/*`"" -ForegroundColor Gray \ No newline at end of file