示例#1
0
        public MFTestResults XmlTest_WsXmlElement()
        {
            /// <summary>
            /// 1. Gets and verifies each of the properties of a WsXmlElement object
            /// 2. Sets and re-verifies all properties
            /// </summary>
            ///
            bool testResult = true;
            try
            {
                WsXmlElement testWXD = new WsXmlElement();

                Log.Comment("LocalName");
                if (testWXD.LocalName != null)
                    if (testWXD.LocalName.GetType() !=
                        Type.GetType("System.String"))
                        throw new Exception("LocalName wrong type");

                testWXD.LocalName = "test datum 1";

                if (testWXD.LocalName.GetType() !=
                    Type.GetType("System.String"))
                    throw new Exception("LocalName wrong type after set");

                if (testWXD.LocalName != "test datum 1")
                    throw new Exception("LocalName wrong data");


                 Log.Comment("NamespaceURI");
                if (testWXD.NamespaceURI != null)
                    if (testWXD.NamespaceURI.GetType() !=
                        Type.GetType("System.String"))
                        throw new Exception("NamespaceURI wrong type");

                testWXD.NamespaceURI = "test datum 3";

                if (testWXD.NamespaceURI.GetType() !=
                    Type.GetType("System.String"))
                    throw new Exception("NamespaceURI wrong type after set");

                if (testWXD.NamespaceURI != "test datum 3")
                    throw new Exception("NamespaceURI wrong data");

                Log.Comment("Prefix");
                if (testWXD.Prefix != null)
                    if (testWXD.Prefix.GetType() !=
                        Type.GetType("System.String"))
                        throw new Exception("Prefix wrong type");

                testWXD.Prefix = "test datum 4";

                if (testWXD.Prefix.GetType() !=
                    Type.GetType("System.String"))
                    throw new Exception("Prefix wrong type after set");

                if (testWXD.Prefix != "test datum 4")
                    throw new Exception("Prefix wrong data");

                Log.Comment("Value");
                if (testWXD.Value != null)
                    if (testWXD.Value.GetType() !=
                        Type.GetType("System.String"))
                        throw new Exception("Value wrong type");

                testWXD.Value = "test datum 5";

                if (testWXD.Value.GetType() !=
                    Type.GetType("System.String"))
                    throw new Exception("Value wrong type after set");

                if (testWXD.Value != "test datum 5")
                    throw new Exception("Value wrong data");

                Log.Comment("Attributes");
                if (testWXD.Attributes != null)
                    if (testWXD.Attributes.GetType() !=
                        Type.GetType("Ws.Services.Xml.WsXmlAttributeCollection"))
                        throw new Exception("Attributes wrong type");

                testWXD.AppendChild(new WsXmlNode());

                if (testWXD.ChildNodes[0].ToString() != new WsXmlNode().ToString())
                    throw new Exception("ChildNodes wrong data");

                if (testWXD.ChildNodes.Count != 1)
                    throw new Exception("Incorrect amount of child nodes.  should be 1 node");

            }
            catch (Exception e)
            {
                testResult = false;
                Log.Comment("Incorrect exception caught: " + e.Message);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }
        public MFTestResults XmlTest_WsXmlElement()
        {
            /// <summary>
            /// 1. Gets and verifies each of the properties of a WsXmlElement object
            /// 2. Sets and re-verifies all properties
            /// </summary>
            ///
            bool testResult = true;

            try
            {
                WsXmlElement testWXD = new WsXmlElement();

                Log.Comment("LocalName");
                if (testWXD.LocalName != null)
                {
                    if (testWXD.LocalName.GetType() !=
                        Type.GetType("System.String"))
                    {
                        throw new Exception("LocalName wrong type");
                    }
                }

                testWXD.LocalName = "test datum 1";

                if (testWXD.LocalName.GetType() !=
                    Type.GetType("System.String"))
                {
                    throw new Exception("LocalName wrong type after set");
                }

                if (testWXD.LocalName != "test datum 1")
                {
                    throw new Exception("LocalName wrong data");
                }


                Log.Comment("NamespaceURI");
                if (testWXD.NamespaceURI != null)
                {
                    if (testWXD.NamespaceURI.GetType() !=
                        Type.GetType("System.String"))
                    {
                        throw new Exception("NamespaceURI wrong type");
                    }
                }

                testWXD.NamespaceURI = "test datum 3";

                if (testWXD.NamespaceURI.GetType() !=
                    Type.GetType("System.String"))
                {
                    throw new Exception("NamespaceURI wrong type after set");
                }

                if (testWXD.NamespaceURI != "test datum 3")
                {
                    throw new Exception("NamespaceURI wrong data");
                }

                Log.Comment("Prefix");
                if (testWXD.Prefix != null)
                {
                    if (testWXD.Prefix.GetType() !=
                        Type.GetType("System.String"))
                    {
                        throw new Exception("Prefix wrong type");
                    }
                }

                testWXD.Prefix = "test datum 4";

                if (testWXD.Prefix.GetType() !=
                    Type.GetType("System.String"))
                {
                    throw new Exception("Prefix wrong type after set");
                }

                if (testWXD.Prefix != "test datum 4")
                {
                    throw new Exception("Prefix wrong data");
                }

                Log.Comment("Value");
                if (testWXD.Value != null)
                {
                    if (testWXD.Value.GetType() !=
                        Type.GetType("System.String"))
                    {
                        throw new Exception("Value wrong type");
                    }
                }

                testWXD.Value = "test datum 5";

                if (testWXD.Value.GetType() !=
                    Type.GetType("System.String"))
                {
                    throw new Exception("Value wrong type after set");
                }

                if (testWXD.Value != "test datum 5")
                {
                    throw new Exception("Value wrong data");
                }

                Log.Comment("Attributes");
                if (testWXD.Attributes != null)
                {
                    if (testWXD.Attributes.GetType() !=
                        Type.GetType("Ws.Services.Xml.WsXmlAttributeCollection"))
                    {
                        throw new Exception("Attributes wrong type");
                    }
                }

                testWXD.AppendChild(new WsXmlNode());

                if (testWXD.ChildNodes[0].ToString() != new WsXmlNode().ToString())
                {
                    throw new Exception("ChildNodes wrong data");
                }

                if (testWXD.ChildNodes.Count != 1)
                {
                    throw new Exception("Incorrect amount of child nodes.  should be 1 node");
                }
            }
            catch (Exception e)
            {
                testResult = false;
                Log.Comment("Incorrect exception caught: " + e.Message);
            }
            return(testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }