Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NonTypedDataSourceGeneratorAttribute #1555

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}

]
Loading
Loading