示例#1
0
        public void TestBuild_NoParameters()
        {
            string definitionName            = "Test";
            AlgorithmDefinition      d       = new AlgorithmDefinition(definitionName, null);
            DefinitionBuilderProcess process = new DefinitionBuilderProcess();
            XElement element = process.Build(d);

            _printXml(element);

            Assert.AreEqual("algorithm", element.Name);
            var nameAttr = element.Attribute("name");

            Assert.AreEqual(definitionName, nameAttr.Value);
        }
示例#2
0
        public void TestBuild_OneParameter()
        {
            AlgorithmDefinition      d       = PluginReflector.CreateDefinition(new ParameterTest());
            DefinitionBuilderProcess process = new DefinitionBuilderProcess();
            XElement element = process.Build(d);

            _printXml(element);

            var properties = (from p in element.Descendants("properties") select p).FirstOrDefault();

            Assert.IsNotNull(properties);

            var allProperties = properties.Descendants("property");

            Assert.IsTrue(allProperties.Any());

            XElement firstProperty = allProperties.First();

            Assert.IsTrue(firstProperty.HasAttributes);

            XAttribute nameAttr = firstProperty.Attribute("name");

            Assert.IsNotNull(nameAttr);
            Assert.AreEqual("Value", nameAttr.Value);

            XAttribute typeAttr = firstProperty.Attribute("type");

            Assert.IsNotNull(typeAttr);
            Type type = Type.GetType(typeAttr.Value);

            Assert.AreEqual(typeof(double), type);

            XAttribute defaultValAttr = firstProperty.Attribute("value");

            Assert.IsNotNull(defaultValAttr);
            Assert.AreEqual("1", defaultValAttr.Value);
        }
示例#3
0
 public void TestBuild_NullDefinition()
 {
     DefinitionBuilderProcess process = new DefinitionBuilderProcess();
     XElement element = process.Build(null);
 }