Skip to content
This repository was archived by the owner on May 2, 2026. It is now read-only.

Testably/Testably.Architecture.Rules

Repository files navigation

DISCONTINUED!

This project is no longer maintained!

Consider using aweXpect.Reflections instead...

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();
    }

About

Enforce architectural rules by documenting expectations as tests.

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages