Skip to content

Commit 28f5be1

Browse files
committed
Fix for constructors with multiple parameters
1 parent 72d88b3 commit 28f5be1

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ A paginator must implement the following methods:
477477

478478
In addition, the constructor must meet the following requirements:
479479

480-
- A paginator must have a constructor with one parameter
480+
- A paginator must have a constructor with one or more parameters
481481
- The first parameter of the constructor is a pageable or scrollable component to be controlled
482482
- The type of the first parameter must be a subclass of `MonoBehaviour`
483483

Runtime/Paginators/IPaginator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ namespace TestHelper.UI.Paginators
1414
/// <remarks>
1515
/// The implementation class must meet the following requirements:
1616
/// <list type="bullet">
17-
/// <item>A paginator must have a constructor with one parameter.</item>
18-
/// <item>The first parameter of the constructor is a pageable or scrollable component to be controlled.</item>
19-
/// <item>The type of the first parameter must be a subclass of <c>MonoBehaviour</c>.</item>
17+
/// <item>A paginator must have a constructor with one or more parameters</item>
18+
/// <item>The first parameter of the constructor is a pageable or scrollable component to be controlled</item>
19+
/// <item>The type of the first parameter must be a subclass of <c>MonoBehaviour</c></item>
2020
/// </list>
2121
/// <seealso cref="TestHelper.UI.Paginators.IPaginatorTest"/>
2222
/// </remarks>

Tests/Runtime/Paginators/IPaginatorTest.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ private static Type[] GetPaginators()
2121
/// Verify that the paginators and supported component type can be obtained via reflection.
2222
/// </summary>
2323
[TestCaseSource(nameof(GetPaginators))]
24-
public void Constructor_HasOneParameter_(Type paginatorType)
24+
public void Constructor_HasOneParameterAndSubclassOfMonoBehaviour(Type paginatorType)
2525
{
2626
var ctor = paginatorType.GetConstructors()
27-
.FirstOrDefault(x => x.GetParameters().Length == 1);
28-
Assume.That(ctor, Is.Not.Null, "The paginator must have a constructor with one parameter.");
27+
.OrderBy(x => x.GetParameters().Length)
28+
.FirstOrDefault(x => x.GetParameters().Length > 0);
29+
Assume.That(ctor, Is.Not.Null, "A paginator must have a constructor with one or more parameters.");
2930

3031
var parameterType = ctor.GetParameters()[0].ParameterType;
3132
Assert.That(parameterType.IsSubclassOf(typeof(MonoBehaviour)), Is.True,
32-
"The first constructor parameter of the paginator must be a MonoBehaviour subclass type.");
33+
"The first parameter of the constructor is a pageable or scrollable component to be controlled, which must be a subclass of MonoBehaviour.");
3334
}
3435
}
3536
}

0 commit comments

Comments
 (0)