How to Unit Test Visual Studio AddIn interacting with VS DOM

ぐ巨炮叔叔 提交于 2019-12-05 23:00:54

This may go some way to answer this... I've got a code sample to create a DTE VS instance which i'm hoping I can then use in my unit test to inject into my class, which interacts with VS, and then hopefully analyse the DTE object to confirm the tests success criteria. I havent got round to trying it within a test but it looks promising.

        DTE2 dte = null;
        try
        {
            Type type = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
            object inst = System.Activator.CreateInstance(type, true);
            dte = (EnvDTE80.DTE2)inst;

            dte.Solution.Open(@"C:\Demo.sln");

            // Inject into class under test

            // Perform the test

            // Analyse the DTE to test for success.

        }
        finally
        {
            if (dte != null)
            {
                dte.Quit();
            }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!