A suite of basic convention tests to run over types to make sure your duckies are all in a row.
Install-Package Best.Conventional
Standard Syntax
new[] { typeof(MyType), typeof(MyOtherType) }
.MustConformTo(
Convention.PropertiesShouldHavePublicGetters.And(
Convention.PropertiesShouldHavePublicSetters))
.WithFailureAssertion(Assert.Fail);
Fluent Syntax
new[] { typeof(MyType), typeof(MyOtherType) }
.MustConformTo(Convention.PropertiesShouldHavePublicGetters)
.AndMustConformTo(Convention.PropertiesShouldHavePublicSetters)
.WithFailureAssertion(Assert.Fail);
Or Mix It Up!
new[] { typeof(MyType), typeof(MyOtherType) }
.MustConformTo(
Convention.PropertiesShouldHavePublicGetters.And(
Convention.PropertiesShouldHavePublicSetters))
.AndMustConformTo(Convention.MustHaveADefaultConstructor)
.WithFailureAssertion(Assert.Fail);
- Properties must have public getters
- Properties must have public setters
- Name must start with
- Name must end with
- Must live in namespace
- Must have a default constructor
- Must have appropriate constructors
- Must have attribute
- Must not take a dependency on
- Requires a corresponding implementation of (T)
- Void methods must not be async
- Enumerable properties must be eager loaded
- Collection properties must be immutable
- All properties must be immutable
A suite of Mono.Cecil-based convention tests, for when standard reflection just wont cut it.
Install-Package Best.Conventional.Cecil
new[] { myAssembly }
.WhereTypes(x => x) // Insert funky type narrowing predicate of choice here
.MustConformTo(CecilConvention.MustNotUseDateTimeNow)
.WithFailureAssertion(Assert.Fail);
- Must not use DateTime.Now
- Must not use DateTimeOffset.Now
- Exceptions thrown must be derived from specified type
- Must instantiate properties of specified type in default constructor