public void ReadTargetOnlyContainingOnError() { ProjectOnErrorElement onError = GetOnError(); Assert.AreEqual("t", onError.ExecuteTargetsAttribute); Assert.AreEqual("c", onError.Condition); }
public void SetExecuteTargetsValid() { ProjectOnErrorElement onError = GetOnError(); onError.ExecuteTargetsAttribute = "t2"; Assert.AreEqual("t2", onError.ExecuteTargetsAttribute); }
internal ProjectOnErrorInstance(ProjectOnErrorElement xml) { condition = xml.Condition; ExecuteTargets = xml.ExecuteTargetsAttribute; //this.FullPath = fullPath; condition_location = xml.ConditionLocation; ExecuteTargetsLocation = xml.ExecuteTargetsAttributeLocation; location = xml.Location; }
public void SetInvalidExecuteTargetsEmpty() { Assert.Throws <ArgumentException>(() => { ProjectOnErrorElement onError = GetOnError(); onError.ExecuteTargetsAttribute = String.Empty; } ); }
public void SetInvalidExecuteTargetsNull() { Assert.Throws <ArgumentNullException>(() => { ProjectOnErrorElement onError = GetOnError(); onError.ExecuteTargetsAttribute = null; } ); }
public static void Verify(ProjectOnErrorElement viewXml, ProjectOnErrorElement realXml, ValidationContext context = null) { if (viewXml == null && realXml == null) { return; } VerifyProjectElement(viewXml, realXml, context); Assert.Equal(realXml.ExecuteTargetsAttribute, viewXml.ExecuteTargetsAttribute); VerifySameLocation(realXml.ExecuteTargetsLocation, viewXml.ExecuteTargetsLocation); }
/// <summary> /// Adds an <OnError /> element to the current target. /// </summary> /// <param name="executeTargets">The targets to execute if a task fails. Separate multiple targets with semicolons. Multiple targets are executed in the order specified.</param> /// <param name="condition">Condition to be evaluated.</param> /// <param name="label">An optional label to add.</param> /// <returns>The current <see cref="ProjectCreator"/>.</returns> public ProjectCreator TargetOnError(string executeTargets, string condition = null, string label = null) { ProjectOnErrorElement onErrorElement = RootElement.CreateOnErrorElement(executeTargets); LastTarget.AppendChild(onErrorElement); onErrorElement.Condition = condition; onErrorElement.Label = label; return(this); }
public void SetExecuteTargets() { ProjectRootElement project = ProjectRootElement.Create(); ProjectTargetElement target = project.AddTarget("t"); ProjectOnErrorElement onError = project.CreateOnErrorElement("et"); target.AppendChild(onError); Helpers.ClearDirtyFlag(project); onError.ExecuteTargetsAttribute = "et2"; Assert.AreEqual("et2", onError.ExecuteTargetsAttribute); Assert.AreEqual(true, project.HasUnsavedChanges); }
public void SetCondition() { ProjectRootElement project = ProjectRootElement.Create(); ProjectTargetElement target = project.AddTarget("t"); ProjectOnErrorElement onError = project.CreateOnErrorElement("et"); target.AppendChild(onError); Helpers.ClearDirtyFlag(project); onError.Condition = "c"; Assert.AreEqual("c", onError.Condition); Assert.AreEqual(true, project.HasUnsavedChanges); }
public void ReadMissingExecuteTargets() { string content = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' > <Target Name='t'> <OnError/> </Target> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectTargetElement target = (ProjectTargetElement)Helpers.GetFirst(project.Children); ProjectOnErrorElement onError = (ProjectOnErrorElement)Helpers.GetFirst(target.Children); Assert.AreEqual(String.Empty, onError.ExecuteTargetsAttribute); }
/// <summary> /// Get a basic ProjectOnErrorElement /// </summary> private static ProjectOnErrorElement GetOnError() { string content = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' > <Target Name='t'> <OnError ExecuteTargets='t' Condition='c'/> </Target> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectTargetElement target = (ProjectTargetElement)Helpers.GetFirst(project.Children); ProjectOnErrorElement onError = (ProjectOnErrorElement)Helpers.GetFirst(target.Children); return(onError); }
private static ProjectOnErrorElement GetOnError() { string content = @" <Project> <Target Name='t'> <OnError ExecuteTargets='t' Condition='c'/> </Target> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectTargetElement target = (ProjectTargetElement)Helpers.GetFirst(project.Children); ProjectOnErrorElement onError = (ProjectOnErrorElement)Helpers.GetFirst(target.Children); return(onError); }
public void ReadEmptyExecuteTargets() { Assert.Throws <InvalidProjectFileException>(() => { string content = @" <Project> <Target Name='t'> <OnError ExecuteTargets=''/> </Target> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectTargetElement target = (ProjectTargetElement)Helpers.GetFirst(project.Children); ProjectOnErrorElement onError = (ProjectOnErrorElement)Helpers.GetFirst(target.Children); Assert.Equal(String.Empty, onError.ExecuteTargetsAttribute); } ); }
public void ReadTargetTwoOnErrors() { string content = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' > <Target Name='t'> <t1/> <t2/> <OnError ExecuteTargets='1'/> <OnError ExecuteTargets='2'/> </Target> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectTargetElement target = (ProjectTargetElement)Helpers.GetFirst(project.Children); var onErrors = Helpers.MakeList(target.OnErrors); ProjectOnErrorElement onError1 = onErrors[0]; ProjectOnErrorElement onError2 = onErrors[1]; Assert.AreEqual("1", onError1.ExecuteTargetsAttribute); Assert.AreEqual("2", onError2.ExecuteTargetsAttribute); }
public void SetInvalidExecuteTargetsEmpty() { ProjectOnErrorElement onError = GetOnError(); onError.ExecuteTargetsAttribute = String.Empty; }
public void SetInvalidExecuteTargetsNull() { ProjectOnErrorElement onError = GetOnError(); onError.ExecuteTargetsAttribute = null; }