protected override Layout GivenLayout()
        {
            var layout = new FlattenedJsonLayout();

            layout.Attributes.Add(new JsonAttribute("flat1", "flat1"));
            return(layout);
        }
        private Target GivenSucceedingTarget(string name)
        {
            var layout = new FlattenedJsonLayout();

            layout.Attributes.Add(new JsonAttribute("success1", "success1"));
            return(new MemoryTarget
            {
                Name = name,
                Layout = layout
            });
        }
        private Target GivenFailingTarget(string name)
        {
            var layout = new FlattenedJsonLayout();

            layout.Attributes.Add(new JsonAttribute("fail1", new FailingLayout()));
            layout.Attributes.Add(new JsonAttribute("flat1", "flat1"));
            return(new MemoryTarget
            {
                Name = name,
                Layout = layout
            });
        }
        private Target GivenTargetWithDuplicates(string name)
        {
            var layout = new FlattenedJsonLayout();

            layout.Attributes.Add(new JsonAttribute("duplicated", "value1"));
            layout.Attributes.Add(new JsonAttribute("duplicated", "value2"));
            layout.Attributes.Add(new JsonAttribute("duplicated", "value3"));

            return(new MemoryTarget
            {
                Name = name,
                Layout = layout
            });
        }
        public void LogEntryIsValidJson()
        {
            var layout = new FlattenedJsonLayout();

            var logProperties = new { ConsumerId = "consumerId", Body = ExamplePushNotification };

            var log = new LogEventInfo(LogLevel.Info, "TheLoggerName", "Received message");

            var propertyDictionary = logProperties.GetType().GetProperties().ToDictionary(x => x.Name, x => x.GetValue(logProperties, null));

            foreach (var element in propertyDictionary)
            {
                log.Properties.Add(element.Key, element.Value);
            }

            string result = layout.Render(log);

            var token = JToken.Parse(result);

            Assert.That(token.HasValues, Is.True);
        }