Пример #1
0
        public void IfEqHelperDetectsInequality()
        {
            var template = Handlebars.Handlebars.Compile("{{#if_eq $Level \"Warning\"}}True{{/if_eq}}");
            var data     = Some.LogEvent();
            var result   = EmailReactor.FormatTemplate(template, data, Some.Host());

            Assert.Equal("", result);
        }
Пример #2
0
        public void BuiltInPropertiesAreRenderedInTemplates()
        {
            var template = Handlebars.Handlebars.Compile("{{$Level}}");
            var data     = Some.LogEvent();
            var result   = EmailReactor.FormatTemplate(template, data, Some.Host());

            Assert.Equal(data.Data.Level.ToString(), result);
        }
Пример #3
0
        public void TrimStringHelper1Arg()
        {
            var template = HandlebarsDotNet.Handlebars.Compile("{{substring $Level}}");
            var data     = Some.LogEvent();
            var result   = EmailReactor.FormatTemplate(template, data, Some.Host());

            Assert.Equal("Fatal", result);
        }
Пример #4
0
        public void PayloadPropertiesAreRenderedInTemplates()
        {
            var template = Handlebars.Handlebars.Compile("See {{What}}");
            var data     = Some.LogEvent(new Dictionary <string, object> {
                { "What", 10 }
            });
            var result = EmailReactor.FormatTemplate(template, data, Some.Host());

            Assert.Equal("See 10", result);
        }
Пример #5
0
        public void NoPropertiesAreRequiredOnASourceEvent()
        {
            var template  = Handlebars.Handlebars.Compile("No properties");
            var id        = Some.EventId();
            var timestamp = Some.UtcTimestamp();
            var data      = new Event <LogEventData>(id, Some.EventType(), timestamp, new LogEventData
            {
                Exception       = null,
                Id              = id,
                Level           = LogEventLevel.Fatal,
                LocalTimestamp  = new DateTimeOffset(timestamp),
                MessageTemplate = "Some text",
                RenderedMessage = "Some text",
                Properties      = null
            });
            var result = EmailReactor.FormatTemplate(template, data, Some.Host());

            Assert.Equal("No properties", result);
        }
Пример #6
0
        public void ToAddressesAreTemplated()
        {
            var mail    = new CollectingMailGateway();
            var reactor = new EmailReactor(mail)
            {
                From = "*****@*****.**",
                To   = "{{Name}}@example.com",
                Host = "example.com"
            };

            reactor.Attach(new TestAppHost());

            var data = Some.LogEvent(new Dictionary <string, object> {
                { "Name", "test" }
            });

            reactor.On(data);

            var sent = mail.Sent.Single();

            Assert.Equal("*****@*****.**", sent.Message.To.ToString());
        }