Inheritance: Microsoft.Build.Tasks.TaskExtension
Exemplo n.º 1
0
        /// <summary>
        /// This method creates a GenerateResource task and performs basic setup on it, e.g. BuildEngine
        /// </summary>
        public static GenerateResource CreateTask()
        {
            // always use the internal ctor that says don't perform separate app domain check
            GenerateResource t = new GenerateResource();
            t.BuildEngine = new MockEngine();

            // Make the task execute in-proc
            t.ExecuteAsTool = false;

            return t;
        }
Exemplo n.º 2
0
        /// <summary>
        /// ExecuteTask performs the task Execute method and asserts basic success criteria
        /// </summary>
        public static void ExecuteTask(GenerateResource t)
        {
            bool success = t.Execute();
            Assert.True(success);

            if (t.OutputResources != null && t.OutputResources[0] != null)
            {
                DateTime resourcesLastModified = File.GetLastWriteTime(t.OutputResources[0].ItemSpec);
                if (t.Sources[0] != null)
                    Assert.True(resourcesLastModified >= File.GetLastWriteTime(t.Sources[0].ItemSpec));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Given an array of ITaskItems, checks to make sure that at least one read tlog and at least one 
        /// write tlog exist, and that they were written to disk.  If that is not true, asserts. 
        /// </summary>
        public static void AssertStateFileWasWritten(GenerateResource t)
        {
            Assert.NotNull(t.FilesWritten); // "The state file should have been written, but there aren't any."
            Assert.NotNull(t.StateFile); // "State file should be defined"
            Assert.True(File.Exists(t.StateFile.ItemSpec)); // "State file should exist"

            bool foundStateFile = false;

            // start from the end because the statefile is usually marked as a written file fairly late in the process
            for (int i = t.FilesWritten.Length - 1; i >= 0; i--)
            {
                if (t.StateFile.ItemSpec.Equals(t.FilesWritten[i].ItemSpec))
                {
                    foundStateFile = true;
                    break;
                }
            }

            Assert.True(foundStateFile); // "Expected there to be a state file, but there wasn't"
        }
Exemplo n.º 4
0
 /// <summary>
 /// Looks for a message in the output log for the task execution., including formatted parameters.
 /// </summary>
 public static void AssertLogNotContains(GenerateResource t, string message)
 {
     Assert.False(((MockEngine)t.BuildEngine).Log.Contains(message));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Looks for a message in the output log for the task execution, including formatted parameters.
 /// </summary>
 public static void AssertLogNotContainsResource(GenerateResource t, string messageID, params object[] replacements)
 {
     Assert.False(((MockEngine)t.BuildEngine).Log.Contains(String.Format(AssemblyResources.GetString(messageID), replacements)));
 }
Exemplo n.º 6
0
        public void MultiTargetingDefaultsSetCorrectly()
        {
            GenerateResource t = new GenerateResource();

            Assert.True(t.ExecuteAsTool); // "ExecuteAsTool should default to true"
        }