コード例 #1
0
 /// <summary>
 /// Helper to get a UsingTaskParameterElement from xml
 /// </summary>
 private static ProjectUsingTaskParameterElement GetParameterXml(string contents)
 {
     ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(contents)));
     ProjectUsingTaskElement usingTask = (ProjectUsingTaskElement)Helpers.GetFirst(project.Children);
     UsingTaskParameterGroupElement parameterGroup = usingTask.ParameterGroup;
     ProjectUsingTaskParameterElement body = Helpers.GetFirst(parameterGroup.Parameters);
     return body;
 }
コード例 #2
0
        public void ReadParameterWithNOAttributes()
        {
            ProjectUsingTaskParameterElement parameter = GetParameterXml(s_contentNoAttributesSet);

            Assert.Equal("MyParameter", parameter.Name);
            Assert.Equal(typeof(String).FullName, parameter.ParameterType);
            Assert.Equal(bool.FalseString, parameter.Output);
            Assert.Equal(bool.FalseString, parameter.Required);
        }
コード例 #3
0
        public void ReadParameterWithAllAttributes()
        {
            ProjectUsingTaskParameterElement parameter = GetParameterXml(s_contentAllAttributesSet);

            Assert.Equal("MyParameter", parameter.Name);
            Assert.Equal("System.String", parameter.ParameterType);
            Assert.Equal("true", parameter.Output);
            Assert.Equal("false", parameter.Required);
        }
コード例 #4
0
        public void SetNullRequired()
        {
            ProjectUsingTaskParameterElement parameter = GetParameterXml(s_contentAllAttributesSet);
            Helpers.ClearDirtyFlag(parameter.ContainingProject);

            parameter.Required = null;
            Assert.Equal(bool.FalseString, parameter.Required);
            Assert.True(parameter.ContainingProject.HasUnsavedChanges);
        }
コード例 #5
0
        public void SetNullType()
        {
            ProjectUsingTaskParameterElement parameter = GetParameterXml(s_contentAllAttributesSet);
            Helpers.ClearDirtyFlag(parameter.ContainingProject);

            parameter.ParameterType = null;
            Assert.Equal(typeof(String).FullName, parameter.ParameterType);
            Assert.True(parameter.ContainingProject.HasUnsavedChanges);
        }
コード例 #6
0
        public void SetEmptyOutput()
        {
            ProjectUsingTaskParameterElement parameter = GetParameterXml(s_contentAllAttributesSet);
            Helpers.ClearDirtyFlag(parameter.ContainingProject);

            parameter.Output = String.Empty;
            Assert.Equal(bool.FalseString, parameter.Output);
            Assert.True(parameter.ContainingProject.HasUnsavedChanges);
        }
コード例 #7
0
        public void SetType()
        {
            ProjectUsingTaskParameterElement parameter = GetParameterXml(s_contentAllAttributesSet);
            Helpers.ClearDirtyFlag(parameter.ContainingProject);

            parameter.ParameterType = "newType";
            Assert.Equal("newType", parameter.ParameterType);
            Assert.True(parameter.ContainingProject.HasUnsavedChanges);
        }
コード例 #8
0
        public void SetRequired()
        {
            ProjectUsingTaskParameterElement parameter = GetParameterXml(s_contentAllAttributesSet);

            Helpers.ClearDirtyFlag(parameter.ContainingProject);

            parameter.Required = "required";
            Assert.Equal("required", parameter.Required);
            Assert.Equal(true, parameter.ContainingProject.HasUnsavedChanges);
        }
コード例 #9
0
        public void SetOutput()
        {
            ProjectUsingTaskParameterElement parameter = GetParameterXml(s_contentAllAttributesSet);

            Helpers.ClearDirtyFlag(parameter.ContainingProject);

            parameter.Output = "output";
            Assert.Equal("output", parameter.Output);
            Assert.Equal(true, parameter.ContainingProject.HasUnsavedChanges);
        }
コード例 #10
0
        public void SetNullOutput()
        {
            ProjectUsingTaskParameterElement parameter = GetParameterXml(contentAllAttributesSet);

            Helpers.ClearDirtyFlag(parameter.ContainingProject);

            parameter.Output = null;
            Assert.AreEqual(bool.FalseString, parameter.Output);
            Assert.AreEqual(true, parameter.ContainingProject.HasUnsavedChanges);
        }
コード例 #11
0
        public void SetEmptyRequired()
        {
            ProjectUsingTaskParameterElement parameter = GetParameterXml(contentAllAttributesSet);

            Helpers.ClearDirtyFlag(parameter.ContainingProject);

            parameter.Required = String.Empty;
            Assert.AreEqual(bool.FalseString, parameter.Required);
            Assert.AreEqual(true, parameter.ContainingProject.HasUnsavedChanges);
        }
コード例 #12
0
        public static void Verify(ProjectUsingTaskParameterElement viewXml, ProjectUsingTaskParameterElement realXml, ValidationContext context = null)
        {
            if (viewXml == null && realXml == null)
            {
                return;
            }

            VerifyProjectElement(viewXml, realXml, context);

            Assert.Equal(realXml.Name, viewXml.Name);
            Assert.Equal(realXml.ParameterType, viewXml.ParameterType);
            VerifySameLocation(realXml.ParameterTypeLocation, viewXml.ParameterTypeLocation, context);
            Assert.Equal(realXml.Output, viewXml.Output);
            VerifySameLocation(realXml.OutputLocation, viewXml.OutputLocation, context);
            Assert.Equal(realXml.Required, viewXml.Required);
            VerifySameLocation(realXml.RequiredLocation, viewXml.RequiredLocation, context);
        }