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

[pull] main from nunit:main #224

Merged
merged 1 commit into from
Aug 4, 2024
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
Expand Up @@ -9,6 +9,7 @@ namespace NUnit.Framework
using Interfaces;
using Internal;
using Internal.Builders;
using NUnit.Framework.Internal.Extensions;

/// <summary>
/// Marks a test as using a particular CombiningStrategy to join any supplied parameter data.
Expand Down Expand Up @@ -61,11 +62,14 @@ public IEnumerable<TestMethod> BuildFrom(IMethodInfo method, Test? suite)

if (parameters.Length > 0)
{
IEnumerable[] sources = new IEnumerable[parameters.Length];
int parametersToSupply = parameters.LastParameterAcceptsCancellationToken() ?
parameters.Length - 1 : parameters.Length;

IEnumerable[] sources = new IEnumerable[parametersToSupply];

try
{
for (int i = 0; i < parameters.Length; i++)
for (int i = 0; i < parametersToSupply; i++)
sources[i] = _dataProvider.GetDataFor(parameters[i]);
}
catch (InvalidDataSourceException ex)
Expand Down
38 changes: 38 additions & 0 deletions src/NUnitFramework/tests/Attributes/CancelAfterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,44 @@ public void TestWithCancelAfterAttributeAndTestCaseSourceHasCancellationToken(in
Assert.That(cancellationToken, Is.EqualTo(TestContext.CurrentContext.CancellationToken));
}

[Test]
[CancelAfter(500)]
public void TestWithCancelAfterAttributeAndValueAttributeHasCancellationToken([Values] bool value, CancellationToken cancellationToken)
{
Assert.Multiple(() =>
{
Assert.That(value, Is.True.Or.False);
Assert.That(cancellationToken, Is.Not.EqualTo(CancellationToken.None));
});
Assert.That(cancellationToken, Is.EqualTo(TestContext.CurrentContext.CancellationToken));
}

[Test]
[CancelAfter(500)]
[Sequential]
public void TestWithCancelAfterAttributeAndMultipleValueAttributesSequentialHasCancellationToken([Values] bool a, [Values] bool b, CancellationToken cancellationToken)
{
Assert.Multiple(() =>
{
Assert.That(a, Is.EqualTo(b));
Assert.That(cancellationToken, Is.Not.EqualTo(CancellationToken.None));
});
Assert.That(cancellationToken, Is.EqualTo(TestContext.CurrentContext.CancellationToken));
}

[Test]
[CancelAfter(500)]
[Pairwise]
public void TestWithCancelAfterAttributeAndMultipleValueAttributesPairwiseHasCancellationToken([Values] bool a, [Values] bool b, CancellationToken cancellationToken)
{
Assert.Multiple(() =>
{
Assert.That(a, Is.EqualTo(b).Or.Not.EqualTo(b));
Assert.That(cancellationToken, Is.Not.EqualTo(CancellationToken.None));
});
Assert.That(cancellationToken, Is.EqualTo(TestContext.CurrentContext.CancellationToken));
}

private static readonly int[] Arguments = { 1 };

[CancelAfter(500)]
Expand Down
Loading