-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NonTypedDataSourceGeneratorAttribute (#1555)
* NonTypedDataSourceGeneratorAttribute * Verify
- Loading branch information
Showing
12 changed files
with
1,026 additions
and
11 deletions.
There are no files selected for viewing
115 changes: 115 additions & 0 deletions
115
TUnit.Core.SourceGenerator.Tests/DataSourceGeneratorTests.NonTyped.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
[ | ||
// <auto-generated/> | ||
#pragma warning disable | ||
using global::System.Linq; | ||
using global::System.Reflection; | ||
using global::TUnit.Core; | ||
using global::TUnit.Core.Extensions; | ||
|
||
namespace TUnit.SourceGenerated; | ||
|
||
[global::System.Diagnostics.StackTraceHidden] | ||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
file partial class AutoDataTests : TUnit.Core.Interfaces.SourceGenerator.ITestSource | ||
{ | ||
[global::System.Runtime.CompilerServices.ModuleInitializer] | ||
public static void Initialise() | ||
{ | ||
SourceRegistrar.Register(new AutoDataTests()); | ||
} | ||
public global::System.Collections.Generic.IReadOnlyList<SourceGeneratedTestNode> CollectTests(string sessionId) | ||
{ | ||
return Tests0(sessionId); | ||
} | ||
private global::System.Collections.Generic.List<SourceGeneratedTestNode> Tests0(string sessionId) | ||
{ | ||
global::System.Collections.Generic.List<SourceGeneratedTestNode> nodes = []; | ||
var classDataIndex = 0; | ||
var testMethodDataIndex = 0; | ||
try | ||
{ | ||
var testClassType = typeof(global::TUnit.TestProject.AutoDataTests); | ||
var methodInfo = global::TUnit.Core.Helpers.MethodInfoRetriever.GetMethodInfo(typeof(global::TUnit.TestProject.AutoDataTests), "Test1", 0, [typeof(global::System.String), typeof(global::System.Int32), typeof(global::System.Double), typeof(global::System.Boolean)]); | ||
|
||
var testBuilderContext = new global::TUnit.Core.TestBuilderContext(); | ||
var testBuilderContextAccessor = new global::TUnit.Core.TestBuilderContextAccessor(testBuilderContext); | ||
var methodArgDataGeneratorMetadata = new DataGeneratorMetadata | ||
{ | ||
Type = TUnit.Core.Enums.DataGeneratorType.Parameters, | ||
TestClassType = testClassType, | ||
ParameterInfos = methodInfo.GetParameters(), | ||
PropertyInfo = null, | ||
TestBuilderContext = testBuilderContextAccessor, | ||
TestSessionId = sessionId, | ||
}; | ||
var methodDataAttribute = new global::TUnit.TestProject.Attributes.AutoDataAttribute() | ||
{ | ||
|
||
}; | ||
|
||
var methodArgGeneratedDataArray = methodDataAttribute.GenerateDataSources(methodArgDataGeneratorMetadata); | ||
|
||
foreach (var methodArgGeneratedDataAccessor in methodArgGeneratedDataArray) | ||
{ | ||
testMethodDataIndex++; | ||
|
||
var methodArgGeneratedData = methodArgGeneratedDataAccessor(); | ||
global::System.String methodArg = (global::System.String)methodArgGeneratedData[0]; | ||
global::System.Int32 methodArg1 = (global::System.Int32)methodArgGeneratedData[1]; | ||
global::System.Double methodArg2 = (global::System.Double)methodArgGeneratedData[2]; | ||
global::System.Boolean methodArg3 = (global::System.Boolean)methodArgGeneratedData[3]; | ||
var resettableClassFactoryDelegate = () => new ResettableLazy<global::TUnit.TestProject.AutoDataTests>(() => | ||
new global::TUnit.TestProject.AutoDataTests() | ||
, sessionId, testBuilderContext); | ||
|
||
var resettableClassFactory = resettableClassFactoryDelegate(); | ||
|
||
nodes.Add(new TestMetadata<global::TUnit.TestProject.AutoDataTests> | ||
{ | ||
TestId = $"global::TUnit.TestProject.Attributes.AutoDataAttribute:{testMethodDataIndex}:TL-GAC0:TUnit.TestProject.AutoDataTests.Test1(System.String,System.Int32,System.Double,System.Boolean):0", | ||
TestClassArguments = [], | ||
TestMethodArguments = [methodArg, methodArg1, methodArg2, methodArg3], | ||
TestClassProperties = [], | ||
CurrentRepeatAttempt = 0, | ||
RepeatLimit = 0, | ||
MethodInfo = methodInfo, | ||
ResettableClassFactory = resettableClassFactory, | ||
TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test1(methodArg, methodArg1, methodArg2, methodArg3)), | ||
TestFilePath = @"", | ||
TestLineNumber = 8, | ||
TestAttributes = [ new global::TUnit.TestProject.Attributes.AutoDataAttribute() | ||
{ | ||
|
||
}, new global::TUnit.Core.TestAttribute() | ||
{ | ||
|
||
} ], | ||
ClassAttributes = [ ], | ||
AssemblyAttributes = [ ], | ||
DataAttributes = [ methodDataAttribute ], | ||
TestBuilderContext = testBuilderContext, | ||
}); | ||
resettableClassFactory = resettableClassFactoryDelegate(); | ||
testBuilderContext = new(); | ||
testBuilderContextAccessor.Current = testBuilderContext; | ||
} | ||
} | ||
catch (global::System.Exception exception) | ||
{ | ||
nodes.Add(new FailedInitializationTest | ||
{ | ||
TestId = $"global::TUnit.TestProject.Attributes.AutoDataAttribute:{testMethodDataIndex}:TL-GAC0:TUnit.TestProject.AutoDataTests.Test1(System.String,System.Int32,System.Double,System.Boolean):0", | ||
TestClass = typeof(global::TUnit.TestProject.AutoDataTests), | ||
ReturnType = global::TUnit.Core.Helpers.MethodInfoRetriever.GetMethodInfo(typeof(global::TUnit.TestProject.AutoDataTests), "Test1", 0, [typeof(global::System.String), typeof(global::System.Int32), typeof(global::System.Double), typeof(global::System.Boolean)]).ReturnType, | ||
ParameterTypeFullNames = [typeof(global::System.String), typeof(global::System.Int32), typeof(global::System.Double), typeof(global::System.Boolean)], | ||
TestName = "Test1", | ||
TestFilePath = @"", | ||
TestLineNumber = 8, | ||
Exception = exception, | ||
}); | ||
} | ||
return nodes; | ||
} | ||
} | ||
|
||
] |
Oops, something went wrong.