Skip to content

Commit d986640

Browse files
committed
fixes bug in ParameterizedResourceFilterAttribute which disabled wrong tests (#349)
1 parent c739e08 commit d986640

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

Cecilifier.Core.Tests/Framework/Attributes/FilterByContextBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ protected bool HasMatchingContext(Test test)
2727
protected bool DisableTestIfNotApplicable(ITest test, string testName)
2828
{
2929
if (_enabledTests.Contains(testName))
30-
return true;
30+
return false;
3131

3232
((Test) test).RunState = RunState.Ignored;
3333
test.Properties[PropertyNames.SkipReason].Add(IgnoreReason);
3434

35-
return false;
35+
return true;
3636
}
3737
}

Cecilifier.Core.Tests/Framework/Attributes/ParameterizedResourceFilterAttribute.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#nullable enable
2+
using System;
23
using Cecilifier.Core.AST;
34
using NUnit.Framework.Interfaces;
45
using NUnit.Framework.Internal.Commands;
56

67
namespace Cecilifier.Core.Tests.Framework.Attributes;
78

9+
[AttributeUsage(AttributeTargets.Method)]
810
internal class ParameterizedResourceFilterAttribute<T> : FilterByContextBase<T>, IWrapTestMethod where T : IVisitorContext
911
{
1012
public ParameterizedResourceFilterAttribute(params string[] enabled) : base(enabled)
@@ -15,7 +17,8 @@ public TestCommand Wrap(TestCommand command)
1517
{
1618
if (HasMatchingContext(command.Test) && command.Test.Arguments.Length > 0)
1719
{
18-
DisableTestIfNotApplicable(command.Test, (string) command.Test.Arguments[0]!);
20+
if(DisableTestIfNotApplicable(command.Test, (string) command.Test.Arguments[0]!))
21+
return new SkipCommand(command.Test);
1922
}
2023
return command;
2124
}

0 commit comments

Comments
 (0)