vs 2012: Shims compile

I am trying to make a shim in VS 2012 ultimate as it described in MSDN site:

public class TestClass1
    public void TestCurrentYear()
        int fixedYear = 2000;

        using (ShimsContext.Create())
          // Arrange:
          // Detour DateTime.Now to return a fixed date:
          System.Fakes.ShimDateTime.NowGet = 
              () =>
              { return new DateTime(fixedYear, 1, 1); };

          // Instantiate the component under test:
          var componentUnderTest = new MyComponent();

          // Act:
          int year = componentUnderTest.GetTheCurrentYear();

          // Assert: 
          // This will always be true if the component is working:
          Assert.AreEqual(fixedYear, year);

see http://msdn.microsoft.com/en-us/library/hh549176.aspx

But when I compile my test project I get a notion in Output:

warning : Some fakes could not be generated. For complete details, set Diagnostic attribute of the Fakes element in this file to 'true' and rebuild the project.

How can I resolve this warning?


Visual Studio 2012 Update 1 improved code generation in Fakes to simplify troubleshooting of code generation problems. Whenever a Stub or a Shim could not be generated for a particular type, Fakes can now generate a warning message - you can see this in the Error List window of Visual Studio.

However, to prevent the number of warnings from becoming overwhelming for a large assembly, such as System, Fakes generates a single warning by default. You can see a complete list of warning messages by setting the Diagnostic attribute of the Fakes XML element in the .Fakes file to "true" or "1" and rebuilding the project. (See the first line of code below for an example.)

To resolve the warning, change the .Fakes file to generate only those Stubs and Shims you need in your tests. Details here here a complete list of available options

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="true">
  <Assembly Name="System" Version=""/>
  <StubGeneration Disable="true" />
    <Add FullName="System.DateTime!"/>

Need Your Help

Could not open Hibernate Session for transaction / Cannot open connection

hibernate spring-mvc spring-security sessionfactory

In my application, I have a module that is designed to search a database for users and display their information in a table inside a jsp. I just setup Spring Security inside my application. I was a...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.