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

Enhancement: Lambda Assertions #68

Closed m-flak closed 3 months ago

m-flak commented 3 months ago

I have a function that takes an entity from an Azure Storage Queue and places it in an Azure Storage Table. I am using this library's TypeTester to test it. It works great, but I can only assert that the operation was successful.

Because there are fields in my table entity that are generated on-the-fly, I can only call AssertSuccess(). I can't use AssertValue(). My only recourse is to visually examine the log output and say, "Yep, that looks good."

It would be great if I could use a lambda with the ValueAssertor<TValue> and perform my comparisons only on the fields I want to check in my TValue.

m-flak commented 3 months ago

I just noticed there is a Result property to access the value, so I could use that.

chullybun commented 3 months ago

Hi.

There should be a number of Assert* methods available, one being AssertValue assuming the type's methods invocation returns a value, to support your requirement.

Also, there is a ExpectLogContains to check that the log output contains the specified text for scenarios where there is no other resultant means to verify the result. See example.

Cheers...