public override void Initialize() { base.Initialize(); generalPropertyPage = new GeneralPropertyPage(); customProjectPackage = new CustomProjectPackage(); ((IVsPackage)customProjectPackage).SetSite(serviceProvider); customProjectFactory = new MyCustomProjectFactory(customProjectPackage); base.SetMsbuildEngine(customProjectFactory); int canCreate; if(VSConstants.S_OK == ((IVsProjectFactory)customProjectFactory).CanCreateProject(projectFile, 2, out canCreate)) { PrivateType type = new PrivateType(typeof(MyCustomProjectFactory)); PrivateObject obj = new PrivateObject(customProjectFactory, type); projectNode = (MyCustomProjectNode)obj.Invoke("PreCreateForOuter", new object[] { IntPtr.Zero }); Guid iidProject = new Guid(); int pfCanceled; projectNode.Load(projectFile, "", "", 2, ref iidProject, out pfCanceled); } }
public void CreateProjectTest() { int actual; int expected = 1; MyCustomProjectFactory customProjectFactory = new MyCustomProjectFactory(customProjectPackage); base.SetMsbuildEngine(customProjectFactory); ((IVsProjectFactory)customProjectFactory).CanCreateProject(projectFile, 2, out actual); Assert.AreEqual(expected, actual, "Cannot create project"); PrivateType type = new PrivateType(typeof(MyCustomProjectFactory)); PrivateObject obj = new PrivateObject(customProjectFactory, type); MyCustomProjectNode projectNode = (MyCustomProjectNode)obj.Invoke("PreCreateForOuter", new object[] { IntPtr.Zero }); Assert.IsNotNull(projectNode, "Cannot create project"); }
public void ConstructorTest() { MyCustomProjectFactory myCustomProjectFactory = new MyCustomProjectFactory(customProjectPackage); Assert.IsNotNull(myCustomProjectFactory, "Constructor failed"); }