Avanade / UnitTestEx

UnitTestEx provides .NET testing extensions to the most popular testing frameworks (MSTest, NUnit and Xunit) specifically to improve the testing experience with ASP.NET controller, and Azure Function, execution including underlying HttpClientFactory mocking.
MIT License
18 stars 4 forks source link

Issues with using expressions #38

Closed karpikpl closed 2 years ago

karpikpl commented 2 years ago

Hey @chullybun I've pushed a branch to show some issues I see with using expressions in UnitTestEx

https://github.com/Avanade/UnitTestEx/blob/77c70fdbcfafeef721fda496b9be44f732f68c1d/tests/UnitTestEx.MSTest.Test/ExpressionTest.cs#L19-L28

chullybun commented 2 years ago

The above is an abuse of the intended expressions capabilities of UnitTestEx. The expressions enable additional logging and features behind the scenes as the function is not immediately executed. For example, in the above, the expression will be automatically converted into an HttpRequest versus calling the expression function directly - it is intended to make using and invoking the test easier (more logical).

UnitTestEx has been updated to throw an InvalidOperationException where the likes of method-chaining are used to invoke. Otherwise, the underlying intended behavior remains unchanged.

@karpikpl, are there other scenarios you have encountered that need to be accounted for here?