Unit Testing MS Dynamics CRM 2015 Plugins with Xrm Test Framework

Posted on Posted in Microsoft, MS CRM 2015, MS Dynamics CRM, Unit Testing

I started a new Plugins project from scratch and wanted to add a unit test project using Xrm test framework by following instructions from the link below

Create Plugin unit test

Added all code as described in documentation above…

Created fake assembly System and Microsoft.Xrm.Sdk

but I was getting errors after debugging my tests and errors were related to versioning conflicts

Screen Shot 2016-01-29 at 19.17.52

Additional information: Could not load file or assembly 'Microsoft.QualityTools.Testing.Fakes, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

After spending sometime below are the steps I followed to fix the issue

  1. removed Microsoft.Xrm.Sdk (and related fakes to it)
  2. removed Microsoft.Xrm.Sdk.fakes from fakes folder
  3. Cleaned solution
  4. Added new Microsoft CRM Sdk 2015 assemblies by right clicking on References>Manage NuGet packages (if you already have packages installed then just go to package and remove references then it will let you reinstall)
  5. Once newly Microsoft.Xrm.Sdk is added under references, right clicked on it and created fake assembly