Testing shared resources with xUnit and Moq

Source code Download source – 9 KB GitHub Introduction xUnit is widely used testing library and the post focuses attention how to write unit tests for classes that uses static properties or shared resources. Several scenarios are considered in the article. Background Solution uses C#7, .Net 4.6.1, NuGet packages Unity and CommonServiceLocator to implement ServiceLocator… Read More Testing shared resources with xUnit and Moq

Xunit and dynamic

Working with XML serialization, I need to create object with several public properties taken from complex “parent” object, and its class is created on the fly via reflection. Full code is accessible on GitHub Blog repository. The following MSDN’s topic contains an example of the creating dynamic class with public property. Let me list sample code that creates… Read More Xunit and dynamic

Xunit and exceptions with async Task

Recently, I wrote Xunit tests for business object that requires to catch exceptions generated by wrong property values in synchronous and asynchronous calls. This post includes several examples and full code is accessible on GitHub Blog repository. Here I will use approach described in Richard Banks’ post Stop Using Assert.Throws in Your BDD Unit Tests… Read More Xunit and exceptions with async Task