diff --git a/ExampleTest/LimitationsOnReleaseTest.cs b/ExampleTest/LimitationsOnReleaseTest.cs index 90b446cf6..fa57616ee 100644 --- a/ExampleTest/LimitationsOnReleaseTest.cs +++ b/ExampleTest/LimitationsOnReleaseTest.cs @@ -1,8 +1,11 @@ using System.Linq; +using System.Threading.Tasks; using ArchUnitNET.Domain; using ArchUnitNET.Domain.Extensions; using ArchUnitNET.Loader; +using ArchUnitNET.xUnit; using Xunit; +using static ArchUnitNET.Fluent.ArchRuleDefinition; namespace ExampleTest { @@ -61,6 +64,17 @@ public void TypeOfDependencyTest() Assert.Contains(_missingDependencyClass, methodWithTypeOfDependencyDependencies); } + + [Fact] + public void AsyncMethodDependencyTest() + { + Classes() + .That() + .Are(typeof(AsyncUser)) + .Should() + .CallAny(MethodMembers().That().HaveName("MethodAsync()")) + .Check(Architecture); + } } #pragma warning disable 219 @@ -85,5 +99,23 @@ public void MethodWithNullVariable() internal class MissingDependencyClass { } internal class SubClass : MissingDependencyClass { } + + internal class AsyncService + { + public async Task MethodAsync() + { + await Task.Delay(100); + } + } + + internal class AsyncUser + { + private readonly AsyncService _asyncService = new AsyncService(); + + public async Task UseAsyncService() + { + await _asyncService.MethodAsync(); + } + } } #pragma warning restore 219 diff --git a/README.md b/README.md index 57a1c3fc4..3dab6b983 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,16 @@ namespace ExampleTest } ``` +#### Run the tests + +Since ArchUnitNET is reading the architecture form the analyzed binaries, it is recommended to run ArchUnitNET-based tests in Debug configuration. + +``` +dotnet test -c Debug +``` + +For more details on known edge cases, see [the documentation](https://archunitnet.readthedocs.io/en/stable/limitations/debug_artifacts/). + #### Further Info and Help Check out test examples for the current release at diff --git a/documentation/docs/limitations/debug_artifacts.md b/documentation/docs/limitations/debug_artifacts.md index 4434868ce..27f91e7cc 100644 --- a/documentation/docs/limitations/debug_artifacts.md +++ b/documentation/docs/limitations/debug_artifacts.md @@ -2,8 +2,9 @@ ArchUnitNET gathers information about the architecture from analyzing binaries, therefore running tests with the Release option (`dotnet test -c Release`) instead of the Debug option (`dotnet test -c Debug`) can lead to not finding dependencies you normally would expect to find. -The edge cases we found so far are not initializing a local variable, casting an object and using -the typeof() statement. A minimal example for each edge case can be found [here](https://github.com/TNG/ArchUnitNET/blob/master/ExampleTest/LimitationsOnReleaseTest.cs). +The edge cases we found so far are not initializing a local variable, casting an object, using +the typeof() statement and checking that an async function is called. +A minimal example for each edge case can be found [here](https://github.com/TNG/ArchUnitNET/blob/master/ExampleTest/LimitationsOnReleaseTest.cs). If you come across another edge case, where executing tests in Debug mode leads to different results than executing