public MFTestResults XmlTest_WsXmlAttributeCollection() { /// <summary> /// 1. Verifies the properties of a WsXmlAttributes object /// 2. Adds elements to it /// 3. Re-verifies /// 4. Empties the object /// 5. Re-verifies /// </summary> /// bool testResult = true; try { WsXmlAttributeCollection testWXAs = new WsXmlAttributeCollection(); if (testWXAs.Count != 0) { throw new Exception("Count did not set correctly on new"); } testWXAs.RemoveAll(); if (testWXAs.Count != 0) { throw new Exception("Count did not set correctly after new ... clear"); } testWXAs.Append(new WsXmlAttribute()); WsXmlAttribute testWXA = new WsXmlAttribute(); testWXAs.Append(testWXA); if (testWXAs.Count != 2) { throw new Exception("Count did not set correctly on new"); } testWXAs.RemoveAll(); if (testWXAs.Count != 0) { throw new Exception("Count did not set correctly after new ... clear"); } } catch (Exception e) { testResult = false; Log.Comment("Incorrect exception caught: " + e.Message); } return(testResult ? MFTestResults.Pass : MFTestResults.Fail); }
/// <summary> /// Builds an Array of XmlAttribute objects containing any attribute that is not required /// ad passes a specified Wildcard namespace validation rules /// </summary> /// <param name="reader">An XmlReader positioned in a document.</param> /// <returns>An array of XmlElements.</returns> /// <remarks>ProcessContent validation is not supported.</remarks> protected WsXmlAttribute[] ReadAnyAttribute(XmlReader reader) { ArrayList attribList = new ArrayList(); if (reader.MoveToFirstAttribute()) { while (true) { if (reader.Name.IndexOf("xmlns") != 0) { bool found = false; for (int i = 0; i < _attributesFound.Count; i++) { if ((String)(_attributesFound[i]) == reader.Name) { found = true; break; } } if (!found) { WsXmlAttribute attrib = new WsXmlAttribute(); attrib.Prefix = reader.Prefix; attrib.LocalName = reader.LocalName; attrib.NamespaceURI = reader.NamespaceURI; attrib.Value = reader.Value; attribList.Add(attrib); } } if (!reader.MoveToNextAttribute()) { break; } } } return((WsXmlAttribute[])attribList.ToArray(typeof(WsXmlAttribute))); }
public MFTestResults XmlTest_WsXmlAttribute() { /// <summary> /// 1. Gets and verifies each of the properties of a WsXmlAttribute object /// 2. Sets and re-verifies all properties /// </summary> /// bool testResult = true; try { WsXmlAttribute testWXA = new WsXmlAttribute(); Log.Comment("LocalName"); if (testWXA.LocalName != null) { if (testWXA.LocalName.GetType() != Type.GetType("System.String")) { throw new Exception("LocalName wrong type"); } } testWXA.LocalName = "test datum 1"; if (testWXA.LocalName.GetType() != Type.GetType("System.String")) { throw new Exception("LocalName wrong type after set"); } if (testWXA.LocalName != "test datum 1") { throw new Exception("LocalName wrong data"); } Log.Comment("NamespaceURI"); if (testWXA.NamespaceURI != null) { if (testWXA.NamespaceURI.GetType() != Type.GetType("System.String")) { throw new Exception("NamespaceURI wrong type"); } } testWXA.NamespaceURI = "test datum 3"; if (testWXA.NamespaceURI.GetType() != Type.GetType("System.String")) { throw new Exception("NamespaceURI wrong type after set"); } if (testWXA.NamespaceURI != "test datum 3") { throw new Exception("NamespaceURI wrong data"); } Log.Comment("Prefix"); if (testWXA.Prefix != null) { if (testWXA.Prefix.GetType() != Type.GetType("System.String")) { throw new Exception("Prefix wrong type"); } } testWXA.Prefix = "test datum 4"; if (testWXA.Prefix.GetType() != Type.GetType("System.String")) { throw new Exception("Prefix wrong type after set"); } if (testWXA.Prefix != "test datum 4") { throw new Exception("Prefix wrong data"); } Log.Comment("Value"); if (testWXA.Value != null) { if (testWXA.Value.GetType() != Type.GetType("System.String")) { throw new Exception("Value wrong type"); } } testWXA.Value = "test datum 5"; if (testWXA.Value.GetType() != Type.GetType("System.String")) { throw new Exception("Value wrong type after set"); } if (testWXA.Value != "test datum 5") { throw new Exception("Value wrong data"); } } catch (Exception e) { testResult = false; Log.Comment("Incorrect exception caught: " + e.Message); } return(testResult ? MFTestResults.Pass : MFTestResults.Fail); }