I have a controller in the admin section of my site and it is decorated with the Authorize filter with the role set to admin.
[Authorize(Roles = "Admin")]
public class SubscriberController : Controller
This works great but I'd like to create a unit test to ensure that the filter is not removed. I've got this far, to validate that the Authorize filter is present.
typeof(SubscriberController).Should()
.BeDecoratedWith<AuthorizeAttribute>(
"Subscriber controller users must be admins");
How can I validate the Roles argument? I am using Fluent Assertion 1.7.1.1.
It is possible now in Fluent Assertion v2:
typeof(SubscriberController).Should()
.BeDecoratedWith<AuthorizeAttribute>(a => a.Roles.Contains("Admin"),
"Subscriber controller users must be admins");