public void Exception()
        {
            var definition = new FluentPatternLayoutDefinition();

            var child  = definition.Exception();
            var layout = (PatternLayout)((ILayoutDefinition)definition).CreateLayout();

            Assert.That(layout.ConversionPattern, Is.EqualTo("%exception"));
        }
        public void NestedDiagnosticContext()
        {
            var definition = new FluentPatternLayoutDefinition();

            var child  = definition.NestedDiagnosticContext();
            var layout = (PatternLayout)((ILayoutDefinition)definition).CreateLayout();

            Assert.That(layout.ConversionPattern, Is.EqualTo("%ndc"));
        }
示例#3
0
        public void BuildFluentPatternDefinitionWithAction()
        {
            var builder = new LayoutDefinitionBuilder();

            FluentPatternLayoutDefinition expected = null;
            var actual = builder.Pattern(x => expected = x);

            Assert.That(actual, Is.SameAs(expected));
        }
        public void Date()
        {
            const string format     = "dd MMM yyyy HH:mm:ss,fff";
            var          definition = new FluentPatternLayoutDefinition();

            var child  = definition.Date(format);
            var layout = (PatternLayout)((ILayoutDefinition)definition).CreateLayout();

            Assert.That(layout.ConversionPattern, Is.EqualTo("%date{" + format + "}"));
        }
        public void Type()
        {
            const int precision  = 5;
            var       definition = new FluentPatternLayoutDefinition();

            var child  = definition.Type(precision);
            var layout = (PatternLayout)((ILayoutDefinition)definition).CreateLayout();

            Assert.That(layout.ConversionPattern, Is.EqualTo("%type{" + precision + "}"));
        }
        public void Literal()
        {
            const string literal    = "foo bar 50% baz";
            var          definition = new FluentPatternLayoutDefinition();

            var child  = definition.Literal(literal);
            var layout = (PatternLayout)((ILayoutDefinition)definition).CreateLayout();

            Assert.That(layout.ConversionPattern, Is.EqualTo(literal.Replace("%", "%%")));
        }
        public void Pattern()
        {
            const string pattern    = "%foobarbaz{blahblah}%message%newline";
            var          definition = new FluentPatternLayoutDefinition();

            var child  = definition.Pattern(pattern);
            var layout = (PatternLayout)((ILayoutDefinition)definition).CreateLayout();

            Assert.That(layout.ConversionPattern, Is.EqualTo(pattern));
        }
        public void Footer()
        {
            const string footer     = "FOOTER";
            var          definition = new FluentPatternLayoutDefinition();

            var child  = definition.Footer(footer);
            var layout = ((ILayoutDefinition)definition).CreateLayout();

            Assert.That(layout.Footer, Is.EqualTo(footer));
        }
        public void Property()
        {
            const string propertyName = "foobar";
            var          definition   = new FluentPatternLayoutDefinition();

            var child  = definition.Property(propertyName);
            var layout = (PatternLayout)((ILayoutDefinition)definition).CreateLayout();

            Assert.That(layout.ConversionPattern, Is.EqualTo("%property{" + propertyName + "}"));
        }
        public void Header()
        {
            const string header     = "HEADER";
            var          definition = new FluentPatternLayoutDefinition();

            var child  = definition.Header(header);
            var layout = ((ILayoutDefinition)definition).CreateLayout();

            Assert.That(layout.Header, Is.EqualTo(header));
        }
        public void Custom()
        {
            const string name    = "foobar";
            const string options = "blah, foo";

            var definition = new FluentPatternLayoutDefinition();

            var child  = definition.Custom <PatternConverter>(name, options);
            var layout = (PatternLayout)((ILayoutDefinition)definition).CreateLayout();

            Assert.That(layout.ConversionPattern, Is.EqualTo("%foobar{blah, foo}"));
        }
        public void ComplexPattern()
        {
            var definition = new FluentPatternLayoutDefinition();

            definition
            .Timestamp().RightJustified().MaximumWidth(10)
            .Space()
            .Level().LeftJustified().MinimumWidth(5)
            .Space()
            .Literal("[").Thread().Literal("]:")
            .Space()
            .Message().NewLine();

            var layout = (PatternLayout)((ILayoutDefinition)definition).CreateLayout();

            Assert.That(layout.ConversionPattern, Is.EqualTo("%.10timestamp %-5level [%thread]: %message%newline"));
        }