BenMorris / NetArchTest

A fluent API for .Net that can enforce architectural rules in unit tests.
MIT License
1.39k stars 82 forks source link

BeInternal / BeNestedInternal #64

Closed kl1mm closed 4 years ago

kl1mm commented 4 years ago

Hey BenMorris, thanks for the cool library! :) Would it be possible to implement a BeInternal and BeNestedInternal method, similar to BePublic and BeNestedPublic?

We have some developers how generate classes from the IDE and forget to adjust the visibility ;)

Best regards kl1mm

kl1mm commented 4 years ago

Hi, thanks to release 1.2.6 and the new CustomRules feature, I could solve my problem.

    // Rule
    internal class IsNestedInternalRule : ICustomRule
    {
        bool ICustomRule.MeetsRule(TypeDefinition type) => type.IsNestedAssembly;
    }

   // ExtensionMehtod
   public static ConditionList BeNestedInternal(this Conditions conditions) 
       => conditions.MeetCustomRule(new IsNestedInternalRule());

    //Usage
    ...
    .And().BeNestedInternal()
    ...

Thanks again for the great Work, we appreciate that! Best regards kl1mm