GetTargetExecutionCount() public method

public GetTargetExecutionCount ( string target ) : int
target string
return int
Example #1
0
        public void Test_If() {
            // create new listener that allows us to track build events
            TestBuildListener listener = new TestBuildListener();

            // run the build
            string result = RunBuild(FormatBuildFile("Target1", "true", "true", string.Empty), listener);

            Assert.AreEqual(1, listener.GetTargetExecutionCount("Target1"), "Target1 should have executed once." + Environment.NewLine + result);
            Assert.AreEqual(1, listener.GetTargetExecutionCount("Target2"), "Target2 should have executed once." + Environment.NewLine + result);
            Assert.AreEqual(0, listener.GetTargetExecutionCount("Target3"), "Target3 should not have executed." + Environment.NewLine + result);
        }
Example #2
0
        public void Test_Depends()
        {
            // create new listener that allows us to track build events
            TestBuildListener listener = new TestBuildListener();

            // run the build
            string result = RunBuild(FormatBuildFile("Target1", "true", "false", "Target2"), listener);

            Assert.AreEqual(1, listener.GetTargetExecutionCount("Target1"), "Target1 should have executed once." + Environment.NewLine + result);
            Assert.AreEqual(1, listener.GetTargetExecutionCount("Target2"), "Target2 should have executed once." + Environment.NewLine + result);
            Assert.AreEqual(1, listener.GetTargetExecutionCount("Target3"), "Target3 should have executed once." + Environment.NewLine + result);
        }
Example #3
0
        public void Test_Wild()
        {
            // create new listener that allows us to track build events
            TestBuildListener listener = new TestBuildListener();

            Project project = CreateFilebasedProject(BuildFragment1);

            //use Project.AttachBuildListeners to attach.
            IBuildListener[] listners = { listener };
            project.AttachBuildListeners(new BuildListenerCollection(listners));

            //add targets like they are added from the command line.
            project.BuildTargets.Add("WildTarget");

            string result = ExecuteProject(project);

            Assert.AreEqual(1, listener.GetTargetExecutionCount("WildTarget"), "WildTarget should have executed once." + Environment.NewLine + result);
            Assert.AreEqual(0, listener.GetTargetExecutionCount("Target"), "Target should not have executed." + Environment.NewLine + result);
        }
Example #4
0
        public void Test_CommandLineTargets()
        {
            // create new listener that allows us to track build events
            TestBuildListener listener = new TestBuildListener();

            Project project = CreateFilebasedProject(BuildFragment2);

            //use Project.AttachBuildListeners to attach.
            IBuildListener[] listners = {listener};
            project.AttachBuildListeners(new BuildListenerCollection(listners));

            //add targets like they are added from the command line.
            project.BuildTargets.Add("Release");
            project.BuildTargets.Add("Build");

            string result = ExecuteProject(project);

            Assert.AreEqual(1, listener.GetTargetExecutionCount("Init"), "'Init' target should have executed once." + Environment.NewLine + result);
            Assert.AreEqual(1, listener.GetTargetExecutionCount("Release"), "'Release' target should have executed once." + Environment.NewLine + result);
            Assert.AreEqual(1, listener.GetTargetExecutionCount("Build"), "'Build' target should have executed once." + Environment.NewLine + result);
        }