MS Visual Studio 2015 Enterprise.
AutoCAD 2009 SP3
I need to generate the shims through Microsoft Fakes Platform for some sealed classes of AcMng.dll, AcDbMgd.dll. I wrote these fakes-files:
<!-- acmgd.fakes -->
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="acmgd" Version="17.2.0.0"/>
<StubGeneration>
<Clear/>
</StubGeneration>
<ShimGeneration>
<Clear />
<Add FullName=
"Autodesk.AutoCAD.ApplicationServices.Application"/>
<Add FullName=
"Autodesk.AutoCAD.ApplicationServices.DocumentCollection"/>
<Add FullName=
"Autodesk.AutoCAD.ApplicationServices.Document"/>
<Add FullName=
"Autodesk.AutoCAD.EditorInput.Editor"/>
</ShimGeneration>
</Fakes>
<!-- acdbmgd.fakes -->
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="acdbmgd" Version="17.2.0.0"/>
<StubGeneration>
<Clear/>
</StubGeneration>
<ShimGeneration>
<Clear />
<Add FullName=
"Autodesk.AutoCAD.DatabaseServices.Database"/>
<Add FullName=
"Autodesk.AutoCAD.DatabaseServices.Transaction"/>
</ShimGeneration>
</Fakes>
The each of these classes is sealed. The *Microsoft Fakes Platform* doesn't create the shim for `Autodesk.AutoCAD.ApplicationServices.Application` (the `ShimApplication` class is not exist in the result):
The type or namespace name ShimApplication does not exist in the namespace Autodesk.AutoCAD.ApplicationServices.Fakes (are you missing an assembly reference?)
I haven't this problem for Document and DocumentCollection types. I marked the problem through the TODO comment in my "HelloWorld" code:
using System;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.QualityTools.Testing.Fakes;
using shim_cad = Autodesk.AutoCAD.ApplicationServices
.Fakes.ShimApplication; // TODO: ShimApplication is not exist.
using Autodesk.AutoCAD.ApplicationServices.Fakes;
using Autodesk.AutoCAD.DatabaseServices.Fakes;
using Autodesk.AutoCAD.EditorInput.Fakes;
using cad = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
namespace msfakes {
[TestClass]
public class UnitTest1 {
/// <summary>
/// Attempt of Microsoft Fakes using for AutoCAD
/// </summary>
[TestMethod]
public void TestMethod1() {
using (ShimsContext.Create()) {
ShimDocument doc = null;
ShimDocumentCollection docs =
new ShimDocumentCollection
() { MdiActiveDocumentGet = () => doc
};
shim_cad.DocumentManagerGet = () => docs;
Assert.IsNull(
cad.DocumentManager.MdiActiveDocument);
}
}
}
}
Anybody knows how to fix it?