Skip to content
Merged
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
25 changes: 23 additions & 2 deletions TUnit.Core/Helpers/ClassConstructorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static class ClassConstructorHelper
return await TryCreateInstanceWithClassConstructor(
attributes,
testClassType,
TestBuilderContext.FromTestContext(testContext, attributes.OfType<IDataSourceAttribute>().FirstOrDefault()),
TestBuilderContext.FromTestContext(testContext, GetDataSourceAttribute(attributes)),
testSessionId);
}

Expand Down Expand Up @@ -70,7 +70,28 @@ public static class ClassConstructorHelper
/// </summary>
public static bool HasClassConstructorAttribute(Attribute[] attributes)
{
return attributes.OfType<ClassConstructorAttribute>().Any();
foreach (Attribute attribute in attributes)
{
if (attribute is ClassConstructorAttribute)
{
return true;
}
}

return false;
}

private static IDataSourceAttribute? GetDataSourceAttribute(IReadOnlyList<Attribute> attributes)
{
foreach (Attribute attribute in attributes)
{
if (attribute is IDataSourceAttribute dataSourceAttribute)
{
return dataSourceAttribute;
}
}

return null;
}

/// <summary>
Expand Down
Loading