Quantcast
Channel: Fluent Assertions
Viewing all articles
Browse latest Browse all 1402

New Post: Cannot test attributes of properties

$
0
0

I'm trying to assert that a particular property on a class has a particular attribute applied, using v1.7.1. The current documentation, suggests that I should be able to use:

 

PropertyInfo result = typeof (CreateUserModel).GetProperty("LoginName");
result.Should().BeDecoratedWith<RequiredAttribute>();

However, this does not work as there is no BeDecoratedWith extension method on the PropertyInfo class - rather there is one on the FluentAssertions class PropertyInfoAssociations. What's the best way of achieving my desired result using FA?

 


Viewing all articles
Browse latest Browse all 1402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>