Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS Fakes Build Unit test failure

Tags:

c#

tfsbuild

We have a VS2013 .net 5.0 Solution (VS2013 Premium) with all Unit tests passing fine locally but failing several tests when running in VS Test Loader by TFS Build with this or similar Exception: System.TypeLoadException: Could not load type 'System.Diagnostics.Fakes.ShimEventLog' from assembly 'System.4.0.0.0.Fakes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0ae41878053f6703'. This is an example of a failing test:

    [TestMethod]
    public void WriteToEventLogTest_HappyPath()
    {
        EventLogEntryType eTypeInfo = EventLogEntryType.Information;
        bool sourceExistCalled = false;
        bool writeEntrycalled = false;

        using (ShimsContext.Create())
        {
            ShimEventLog.SourceExistsString = s =>
            {
                sourceExistCalled = true;
                return true;
            };

            ShimEventLog.AllInstances.WriteEntryStringEventLogEntryType = (@this, str, et) =>
            {
                writeEntrycalled = true;
            };

            Logging.WriteToEventLog(IpAddress, eTypeInfo);
            Assert.IsTrue(sourceExistCalled, "SourceExist() not called");
            Assert.IsTrue(writeEntrycalled, "WriteEntry() not called");
        }
    }`

We using TFS 2013 update 5 running on Windows Server 2012 R2. Is there anything that can likely cause this problem? Should we update TFS to the latest which is Update 5 at the moment?

like image 926
Victor Avatar asked Sep 11 '15 14:09

Victor


1 Answers

Problem was resolved by sharing fakes configuration files between the Test projects on a Solution level

like image 84
Victor Avatar answered Oct 21 '22 06:10

Victor