Skip to content

Latest commit

 

History

History
41 lines (35 loc) · 2.1 KB

README.md

File metadata and controls

41 lines (35 loc) · 2.1 KB

Testably.Architecture.Rules
Nuget Build Codacy Badge Coverage Mutation testing badge

This library is used to define architecture rules as expectations that can be run and checked as part of the unit test execution.

Examples

  • Test classes should have Tests as suffix:

    [Fact]
    public void ExpectTestClassesToBeSuffixedWithTests()
    {
      IRule rule = Expect.That.Types
          .Which(Have.Method.WithAttribute<FactAttribute>().OrAttribute<TheoryAttribute>())
          .ShouldMatchName("*Tests");
    
      rule.Check
          .InAllLoadedAssemblies()
          .ThrowIfViolated();
    }
  • Methods that return Task should have Async as suffix:

    [Fact]
    public void AsyncMethodsShouldHaveAsyncSuffix()
    {
      IRule rule = Expect.That.Methods
        .WithReturnType<Task>().OrReturnType(typeof(Task<>))
        .ShouldMatchName("*Async")
        .AllowEmpty();
    
      rule.Check
        .InTestAssembly()
        .ThrowIfViolated();
    }