I've to write unit tests for VSTO Plugin code. So, in my plugin, there is the main add-in class, ThisAddIn
which has following declaration:
namespace NS
{
public partial class ThisAddIn
{ private void ThisAddIn_Startup(object sender, System.EventArgs e){...}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e){...}
}
}
Now, I can see in IDE that this is how it's being initialised in ThisAddIn.Designer.cs
class:
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
public ThisAddIn(global::Microsoft.Office.Tools.Outlook.Factory factory, global::System.IServiceProvider serviceProvider) :
base(factory, serviceProvider, "AddIn", "ThisAddIn") {
Globals.Factory = factory;
}
I referred this post: How to create constructor of ThisAddIn class in VSTO But could not take find something which will help me. Reason of explicitly creating this class's object is for writing unit tests for VSTO plugin. How can I create these input parameters and pass into the constructor call? Also, is this the right way to write unit test for the VSTO plugin?