Skip to content

Enforce architectural rules by documenting expectations as tests.

License

Notifications You must be signed in to change notification settings

Testably/Testably.Architecture.Rules

Folders and files

NameName
Last commit message
Last commit date
Dec 28, 2024
May 6, 2023
Sep 4, 2024
Jan 14, 2025
Apr 22, 2023
Apr 22, 2023
Apr 22, 2023
Apr 22, 2023
May 6, 2023
Apr 22, 2023
May 28, 2023
May 7, 2023
May 27, 2023
Apr 22, 2023
Apr 22, 2023

Repository files navigation

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

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages