Beispiel #1
0
        public void MultipleAdditionalFiles_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Vbc vbc = new Vbc();
            vbc.BuildEngine = mockEngine;

            MockVbcAnalyzerHostObject vbcHostObject = new MockVbcAnalyzerHostObject();
            vbcHostObject.SetDesignTime(true);

            vbc.HostObject = vbcHostObject;
            vbc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(vbcHostObject.AdditionalFiles);

            vbc.AdditionalFiles = new TaskItem[]
            {
                new TaskItem("web.config"),
                new TaskItem("app.config")
            };

            vbc.Sources = new TaskItem[] { new TaskItem("a.cs") };

            bool vbcSuccess = vbc.Execute();

            Assert.IsTrue(vbcSuccess, "Vbc task failed.");

            Assert.AreEqual(2, vbcHostObject.AdditionalFiles.Length);
            Assert.AreEqual("web.config", vbcHostObject.AdditionalFiles[0].ItemSpec);
            Assert.AreEqual("app.config", vbcHostObject.AdditionalFiles[1].ItemSpec);
        }
Beispiel #2
0
        public void RuleSet_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Vbc vbc = new Vbc();
            vbc.BuildEngine = mockEngine;

            MockVbcAnalyzerHostObject vbcHostObject = new MockVbcAnalyzerHostObject();
            vbcHostObject.SetDesignTime(true);

            vbc.HostObject = vbcHostObject;
            vbc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(vbcHostObject.RuleSet);

            vbc.CodeAnalysisRuleSet = "Bar.ruleset";

            vbc.Sources = new TaskItem[] { new TaskItem("a.vb") };

            bool vbcSuccess = vbc.Execute();

            Assert.IsTrue(vbcSuccess, "Vbc task failed.");
            Assert.AreEqual("Bar.ruleset", vbcHostObject.RuleSet);
        }
Beispiel #3
0
        public void NoAdditionalFile_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Vbc vbc = new Vbc();
            vbc.BuildEngine = mockEngine;

            MockVbcAnalyzerHostObject vbcHostObject = new MockVbcAnalyzerHostObject();
            vbcHostObject.SetDesignTime(true);

            vbc.HostObject = vbcHostObject;
            vbc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(vbcHostObject.AdditionalFiles);

            vbc.Sources = new TaskItem[] { new TaskItem("a.cs") };

            bool vbcSuccess = vbc.Execute();

            Assert.IsTrue(vbcSuccess, "Vbc task failed.");
            Assert.IsNull(vbcHostObject.AdditionalFiles);
        }
Beispiel #4
0
        public void Analyzer_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Vbc vbc = new Vbc();
            vbc.BuildEngine = mockEngine;

            MockVbcAnalyzerHostObject vbcHostObject = new MockVbcAnalyzerHostObject();
            vbcHostObject.SetDesignTime(true);

            vbc.HostObject = vbcHostObject;
            vbc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(vbcHostObject.Analyzers);

            vbc.Analyzers = new TaskItem[]
            {
                new TaskItem("Foo.dll")
            };

            vbc.Sources = new TaskItem[] { new TaskItem("a.vb") };
            bool vbcSuccess = vbc.Execute();

            Assert.IsTrue(vbcSuccess, "Vbc task failed.");
            Assert.AreEqual(1, vbcHostObject.Analyzers.Length);
            Assert.AreEqual("Foo.dll", vbcHostObject.Analyzers[0].ItemSpec);
        }