public void SimpleTest()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(@"
            <nlog>
                <targets>
                    <target name='d' type='Debug' layout='${message}' />
                </targets>
            </nlog>");

            LoggingConfiguration c = new XmlLoggingConfiguration(doc.DocumentElement, null);
            DebugTarget t = c.FindTargetByName("d") as DebugTarget;
            Assert.IsNotNull(t);
            Assert.AreEqual(t.Name, "d");
            Assert.AreEqual("${message}", t.Layout);
            Layout l = t.CompiledLayout as Layout;
            Assert.IsNotNull(l);
            Assert.AreEqual(1, l.Renderers.Length);
            Assert.IsInstanceOfType(typeof(MessageLayoutRenderer), l.Renderers[0]);
        }
        public void WrapperTest()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(@"
            <nlog>
                <targets>
                    <target name='b' type='BufferingWrapper' bufferSize='19'>
                        <target name='a' type='AsyncWrapper'>
                            <target name='c' type='Debug' layout='${message}' />
                        </target>
                    </target>
                </targets>
            </nlog>");

            LoggingConfiguration c = new XmlLoggingConfiguration(doc.DocumentElement, null);
            Assert.IsNotNull(c.FindTargetByName("a"));
            Assert.IsNotNull(c.FindTargetByName("b"));
            Assert.IsNotNull(c.FindTargetByName("c"));

            Assert.IsInstanceOfType(typeof(BufferingTargetWrapper), c.FindTargetByName("b"));
            Assert.IsInstanceOfType(typeof(AsyncTargetWrapper), c.FindTargetByName("a"));
            Assert.IsInstanceOfType(typeof(DebugTarget), c.FindTargetByName("c"));

            BufferingTargetWrapper btw = c.FindTargetByName("b") as BufferingTargetWrapper;
            AsyncTargetWrapper atw = c.FindTargetByName("a") as AsyncTargetWrapper;
            DebugTarget dt = c.FindTargetByName("c") as DebugTarget;

            Assert.AreSame(atw, btw.WrappedTarget);
            Assert.AreSame(dt, atw.WrappedTarget);
            Assert.AreEqual(19, btw.BufferSize);
        }
        public void CompoundTest()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(@"
            <nlog>
                <targets>
                    <target name='rr' type='RoundRobinGroup'>
                        <target name='d1' type='Debug' layout='${message}1' />
                        <target name='d2' type='Debug' layout='${message}2' />
                        <target name='d3' type='Debug' layout='${message}3' />
                        <target name='d4' type='Debug' layout='${message}4' />
                    </target>
                </targets>
            </nlog>");

            LoggingConfiguration c = new XmlLoggingConfiguration(doc.DocumentElement, null);

            Assert.IsNotNull(c.FindTargetByName("rr"));
            Assert.IsNotNull(c.FindTargetByName("d1"));
            Assert.IsNotNull(c.FindTargetByName("d2"));
            Assert.IsNotNull(c.FindTargetByName("d3"));
            Assert.IsNotNull(c.FindTargetByName("d4"));

            Assert.IsInstanceOfType(typeof(RoundRobinTarget), c.FindTargetByName("rr"));
            Assert.IsInstanceOfType(typeof(DebugTarget), c.FindTargetByName("d1"));
            Assert.IsInstanceOfType(typeof(DebugTarget), c.FindTargetByName("d2"));
            Assert.IsInstanceOfType(typeof(DebugTarget), c.FindTargetByName("d3"));
            Assert.IsInstanceOfType(typeof(DebugTarget), c.FindTargetByName("d4"));

            RoundRobinTarget rr = c.FindTargetByName("rr") as RoundRobinTarget;
            DebugTarget d1 = c.FindTargetByName("d1") as DebugTarget;
            DebugTarget d2 = c.FindTargetByName("d2") as DebugTarget;
            DebugTarget d3 = c.FindTargetByName("d3") as DebugTarget;
            DebugTarget d4 = c.FindTargetByName("d4") as DebugTarget;

            Assert.AreEqual(4, rr.Targets.Count);
            Assert.AreSame(d1, rr.Targets[0]);
            Assert.AreSame(d2, rr.Targets[1]);
            Assert.AreSame(d3, rr.Targets[2]);
            Assert.AreSame(d4, rr.Targets[3]);

            Assert.AreEqual(d1.Layout, "${message}1");
            Assert.AreEqual(d2.Layout, "${message}2");
            Assert.AreEqual(d3.Layout, "${message}3");
            Assert.AreEqual(d4.Layout, "${message}4");
        }