Dienstag, 30. Juni 2015

Shipping tests along with production code



With NEdifis we advocate putting tests right beside the code rather than into separate test projects. Both approaches have its pros and cons, yet the more popular still seems to be putting tests into a separate test project, see for example Mark Seemann: Where to put unit tests or StackOverflow: Do you put unit tests in same project or another project? The most common reasons for separated test projects are:

Mittwoch, 10. Juni 2015

"To throw or not to throw": Asserting exceptions on tasks with async/await

For testing exceptional behaviour i like using FluentAssertions Invoking extensions. However, i noticed that using this with async/await seems not to be supported and requires unelegant rewriting (Please, prove me wrong on this). However, using C# 6 await in try-catch this is now very simple to do:

Mittwoch, 3. Juni 2015

Reducing repetition in native wrappers using expression bodied members

Whenever wrapping legacy or native APIs in .NET i hate the verbosity of the code that needs to be written. APIs without a concept of exceptions are often designed returning error codes which requires results to be passed back per reference. In .NET this translates to using out-Parameters.