Skip to content

Commit eb166dd

Browse files
[CORELIB-356] - Add a test case for array parameters in attributes
1 parent 6251a6a commit eb166dd

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using LeanCode.Contracts;
2+
using LeanCode.Contracts.Security;
3+
4+
[AuthorizeWhenHasAnyOf(new[] { "P1", "P2" })]
5+
public class A : ICommand { }
6+
7+
[AuthorizeWhenHasAnyOf("P1", "P2")]
8+
public class B : ICommand { }

src/LeanCode.ContractsGenerator.Tests/ExampleBased/Attributes.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,23 @@ public void AuthorizeWhen_attribute_is_correctly_propagated()
7070
.WithDto("AuthorizeWhenCustomGenericAttribute")
7171
.ThatExtends(Known(KnownType.AuthorizeWhenAttribute));
7272
}
73+
74+
[Fact]
75+
public void AuthorizeWhen_array_params()
76+
{
77+
"attributes/authorize_when_array_params.cs"
78+
.Compiles()
79+
.WithCommand("A")
80+
.WithAttribute(
81+
"LeanCode.Contracts.Security.AuthorizeWhenHasAnyOfAttribute",
82+
Positional(0, "P1"),
83+
Positional(1, "P2")
84+
)
85+
.WithCommand("B")
86+
.WithAttribute(
87+
"LeanCode.Contracts.Security.AuthorizeWhenHasAnyOfAttribute",
88+
Positional(0, "P1"),
89+
Positional(1, "P2")
90+
);
91+
}
7392
}

0 commit comments

Comments
 (0)