public void TestClassInheritanceSetsAll() { var obj = new XmlClassInherit(); _doc.LoadXml("<body><int>3</int><subclassInt>42</subclassInt></body>"); XmlPropertyAttribute.BindXml(_doc.DocumentElement, obj); Assert.AreEqual(3, obj.Int); Assert.AreEqual(42, obj.SubClassInt); }
/// <inheritdoc/> /// <summary> /// Returns direct URL to file if it is a File item, otherwise /// builds url from items /// </summary> public override Item DoApply(Item root) { // populate properties from xml XmlPropertyAttribute.BindXml(root.node, this); // log info Log(nameof(DoApply), $"Generating URL for {Type} ID {Id})"); // generate url var url = Type == "File" ? Innovator.getFileUrl(Id, UrlType.None) : $"{BaseUrl}/default.aspx?StartItem={Type}:{Id}"; // return result return(Innovator.newResult(url)); }
public void TestRequiredSet() { _doc.LoadXml("<body><int>3</int></body>"); XmlPropertyAttribute.BindXml(_doc.DocumentElement, _objReq); Assert.AreEqual(3, _objReq.Int); }
public void TestDefaultName() { _doc.LoadXml("<body><int>47</int></body>"); XmlPropertyAttribute.BindXml(_doc.DocumentElement, _obj); Assert.AreEqual(47, _obj.Int); }
public void TestConvert() { _doc.LoadXml("<body><thebool>true</thebool></body>"); XmlPropertyAttribute.BindXml(_doc.DocumentElement, _obj); Assert.AreEqual(true, _obj.Bool); }
public void TestBindSimple() { _doc.LoadXml("<body><thestring>42</thestring></body>"); XmlPropertyAttribute.BindXml(_doc.DocumentElement, _obj); Assert.AreEqual("42", _obj.String); }
public void TestIgnoresText() { _doc.LoadXml("<body> bah </body>"); XmlPropertyAttribute.BindXml(_doc.DocumentElement, _obj); Assert.AreEqual(null, _obj.String); }
public void TestBindNothing() { _doc.LoadXml("<body></body>"); XmlPropertyAttribute.BindXml(_doc.DocumentElement, _obj); Assert.AreEqual(null, _obj.String); }
public void TestUnknownElementNameThrows() { _doc.LoadXml("<body><fail>indeed</fail></body>"); ExceptionAssert.Throws <XmlException>(() => XmlPropertyAttribute.BindXml(_doc.DocumentElement, _objReq)); }
public void TestMissingRequiredThrows() { _doc.LoadXml("<body></body>"); ExceptionAssert.Throws <XmlException>(() => XmlPropertyAttribute.BindXml(_doc.DocumentElement, _objReq)); }