I have an "Application-level" VSTO Add-in (as opposed to "Document-Level") that runs in Excel. The Add-in runs fine. Rather than the Ribbon designer, I'm using the Ribbon XML option. In doing so, you end up with a Ribbon class that derives from Office.IRibbonExtensibility, with various methods such as:
public void OnTextButton(Office.IRibbonControl control)
{ ....
}
etc.
Now, when I create a unit-test project, add a reference to my add-in, then select "Add Fake Assembly" from the right-click menu under References, I get a errors.
I don't believe it has anything to do with my project because I verified that the same thing happens with sample add-in code, such as this project: http://www.codeproject.com/Articles/296288/Excel-Add-in-for-Exporting-Excel-data-to-XML
To reproduce, I downloaded that Add in: 1. Open it in Visual Studeio 2010/2012/2013 2. Create a Unit Test project in the same solution. 3. Add the Add-in Project as solution-level Reference to the Unit Test project. In this particular sample, it's called "ExcelExportXML". 4. Then Expand the References tree in the Unit Test project, right click on the add-in reference, i.e. ExcelExportXML, and select "Add Fake Assembly". This requires that you have at least Premium version of Visual Studio. Professional version is not enough.
You end up with errors such as this:
error CS0234: The type or namespace name 'IRibbonControl' does not exist in the namespace 'eexml::Microsoft.Office.Core' (are you missing an assembly reference?) [...\UnitTestProject1\obj\Debug\Fakes\eexml\f.csproj]
It's best to repeat the steps above to reproduce the problem -- it only takes a few minutes.
My request is this. Is there a way to make this work without switching to another mocking/isolator framework. I really want to avoid anyone suggesting that I not use "Microsoft Fakes Framework" because that's really not useful input unless you're absolutely positive that there is no way to get the two Microsoft technologies to effectively play together.
I've already tried using in the .fakes file in all sorts of combinations. Here's what I've tried so far:
<StubGeneration>
<Clear />
<Remove TypeName="Ribbon1" />
<Remove TypeName="ExcelAddIn1.Ribbon1" />
<Remove FullName="ExcelAddIn1.Ribbon1"/>
<Remove Namespace="ExcelAddIn1"/>
<Remove Namespace="Microsoft.Office.Core"/>
<Remove Namespace="eexml::Microsoft.Office.Core"/>
<Remove FullName="Microsoft.Office.Core.IRibbonControl"/>
<Remove TypeName="IRibbonControl"/>
</StubGeneration>
I spent about half a day researching this. Any help (short of splitting the assembly into VSTO and non-VSTO parts) would be greatly appreciated.