Пример #1
0
        public void BuildPropertyShouldBuildSubFolderOnExistingVariable()
        {
            var toolsProperty = new Property("dirTools", "${dirBase}\\tools");

            _project.AddProperty(toolsProperty);

            _subject.CreatePropertySetter(_dirBaseProperty);

            string output = _subject.CreatePropertySetter(toolsProperty);

            Assert.That(output, Is.EqualTo("_dirTools = _dirBase.SubFolder(\"tools\");"));
        }
Пример #2
0
 public void Setup()
 {
     _project         = new BuildProject();
     _dirBaseProperty = new Property("dirBase", "c:\\temp");
     _project.AddProperty(_dirBaseProperty);
     _subject = new OutputGenerator(_project);
 }
        public BuildProject ParseDocument(XDocument document)
        {
            var buildProject = new BuildProject();
            var parser       = new TargetParser();

            var projectNode = document.Root; //get the project node

            if (projectNode == null)
            {
                throw new ApplicationException("Could not open root node");
            }

            if (projectNode.Attribute("default") != null)
            {
                buildProject.DefaultTarget = projectNode.Attribute("default").Value;
            }

            foreach (var childNode in projectNode.Elements("property"))
            {
                var property = new Property(childNode.Attribute("name").Value, childNode.Attribute("value").Value);
                buildProject.AddProperty(property);
            }

            foreach (var childNode in projectNode.Elements("target"))
            {
                buildProject.Targets.Add(parser.Parse(childNode, buildProject));
                //childNode.Attribute("name").Value.Replace(".", "_"), childNode.ToString());
            }

            IEnumerable <XElement> unkownElements = from XElement unkownElement in projectNode.Elements()
                                                    where
                                                    unkownElement.Name != "target" &&
                                                    unkownElement.Name != "property"
                                                    select unkownElement;

            foreach (XElement unkownElement in unkownElements)
            {
                buildProject.Unkown.Add(unkownElement.Name.ToString(), unkownElement.ToString());
            }
            return(buildProject);
        }