Inheritance: Microsoft.Build.Tasks.TaskExtension
Esempio 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;
        }
Esempio 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));
            }
        }
Esempio 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"
        }
Esempio 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));
 }
Esempio 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)));
 }
Esempio n. 6
0
        public void MultiTargetingDefaultsSetCorrectly()
        {
            GenerateResource t = new GenerateResource();

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