Ejemplo n.º 1
0
                /// <summary>
                /// Tests the WriteTo method on XComment.
                /// </summary>
                /// <param name="contextValue"></param>
                /// <returns></returns>
                //[Variation(Desc = "CommentWriteTo")]
                public void CommentWriteTo()
                {
                    XComment c = new XComment("abcd ");

                    // Null writer not allowed.
                    try
                    {
                        c.WriteTo(null);
                        Validate.ExpectedThrow(typeof(ArgumentNullException));
                    }
                    catch (Exception ex)
                    {
                        Validate.Catch(ex, typeof(ArgumentNullException));
                    }

                    // Test.
                    StringBuilder stringBuilder = new StringBuilder();
                    XmlWriter     xmlWriter     = XmlWriter.Create(stringBuilder);

                    xmlWriter.WriteStartElement("x");
                    c.WriteTo(xmlWriter);
                    xmlWriter.WriteEndElement();

                    xmlWriter.Flush();

                    Validate.IsEqual(
                        stringBuilder.ToString(),
                        "<?xml version=\"1.0\" encoding=\"utf-16\"?><x><!--abcd --></x>");
                }
Ejemplo n.º 2
0
        public void CommentWriteTo()
        {
            XComment c = new XComment("abcd ");

            // Null writer not allowed.
            Assert.Throws <ArgumentNullException>(() => c.WriteTo(null));

            // Test.
            StringBuilder stringBuilder = new StringBuilder();
            XmlWriter     xmlWriter     = XmlWriter.Create(stringBuilder);

            xmlWriter.WriteStartElement("x");
            c.WriteTo(xmlWriter);
            xmlWriter.WriteEndElement();

            xmlWriter.Flush();

            Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-16\"?><x><!--abcd --></x>", stringBuilder.ToString());
        }
Ejemplo n.º 3
0
        private void WriteDocument(XmlWriter writer)
        {
            var Copyright = new XComment("Copyright (c) 2008-2015 New Relic, Inc.  All rights reserved.");

            Copyright.WriteTo(writer);

            var MoreInfo = new XComment("For more information see: https://newrelic.com/docs/dotnet/dotnet-agent-configuration");

            MoreInfo.WriteTo(writer);

            var CreatedBy = new XComment("Created or modified by the New Relic .Net Configuration Tool.");

            CreatedBy.WriteTo(writer);

            XRoot.WriteTo(writer);
            writer.Flush();
            writer.Close();
        }