Ejemplo n.º 1
0
        public void TestSingleFileGeneratorOnNodes()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                //Create a project and get the first filenode
                string destination  = Path.Combine(TestContext.TestDir, TestContext.TestName);
                ProjectNode project = Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                MethodInfo mi = typeof(FileNode).GetMethod("CreateSingleFileGenerator", BindingFlags.Instance | BindingFlags.NonPublic);

                List <FileNode> nodes = Utilities.GetNodesOfType <FileNode>(project);
                foreach (FileNode node in nodes)
                {
                    ISingleFileGenerator generator = mi.Invoke(node, new object[] { }) as ISingleFileGenerator;
                    string extension = Path.GetExtension(node.GetMkDocument());
                    if (String.Compare(extension, ".moxl", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        Assert.IsNull(generator, "There should be no single file generators defined for a moxl file");
                        Assert.IsFalse(node.NodeProperties is SingleFileGeneratorNodeProperties, "If no generators are supported then the properties should not be of type SingleFileGeneratorNodeProperties");
                    }
                    else if (String.Compare(extension, ".cs", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        Assert.IsNotNull(generator, "There should be a single file generator defined for a cs file");
                        Assert.IsTrue(node.NodeProperties is SingleFileGeneratorNodeProperties, "The properties for a node supporting single file generators should be of type SingleFileGeneratorNodeProperties");
                    }
                }
            });
        }
        /// <summary>
        /// Runs a generator.
        /// </summary>
        internal void RunGenerator()
        {
            ISingleFileGenerator generator = this.CreateSingleFileGenerator();

            if (generator != null)
            {
                generator.RunGenerator(this.Url);
            }
        }
        protected override NodeProperties CreatePropertiesObject()
        {
            ISingleFileGenerator generator = this.CreateSingleFileGenerator();

            return(generator == null ? new FileNodeProperties(this) : new SingleFileGeneratorNodeProperties(this));
        }