In most unit test tutorials I follow it has me create a second unit test project and then add a solution/project reference from the test project to the other project.
I have a VSTO addin, and when I go to add the reference I don't see anything listed under Solution > Project.
Why is this? How else can I add a reference to the addin project to test it?
Best How To :
If this is your first time at unit testing, then VSTO might be a steep learning curve. As suggested by @Sam Holder, you might want to put some of your logic into a separate assembly to encourage you to separate your logic from your interactions with the office infrastructure.
That said, whilst you can't add the project using the normal approach of adding a reference to the project, you can add a reference to the output from that project using the
- Right click on the test project and select "Add Reference".
- In the Box the appears, click on the "Browse" button at the bottom.
- Navigate to the bin\debug folder of the VSTO project and select the projects dll.
- Click on OK.
Obviously, you will have had to have built the addin for the above to work.
You're going to face some other challenges if you start trying to create objects that rely on the office infrastructure. So, at a minimum you might need to add references to
Microsoft.Office.Tools.Common into your test project.