Microsoft Fakes is a tool that allows you to replace any method of any .NET class. This makes it ideal for testing untestable code, for example code that uses
DateTime.Now in its implementation...
However when using Microsoft Fakes with
mscorlib.dll, the assembly that contains
DateTime, you will encounter an error
The type or namespace name 'EventSourceCreatedEventArgs' does not exist in the
namespace 'System.Diagnostics.Tracing' (are you missing an assembly reference?)
This actually should not be a problem, because it is actually a sign of something else: that you're faking too much (no pun intended :). Using Microsoft Fakes will generate a fake type for every type in the target assembly, which is very wastefull of resources. You should actually only fake the type you're testing.
Open the fakes file (for example
<Assembly Name="mscorlib" Version="22.214.171.124"/>
<Add FullName="System.DateTime!" />
As you can see here, you add each type you want to stub/shim in the
For more information about this, you can find more documentation at https://msdn.microsoft.com/en-us/library/hh708916.aspx#BKMK_Configuring_code_generation_of_stubs