Exemple #1
0
        public void AdaptLayoutShouldFormatEventWithAttributeKey()
        {
            //var appender = Substitute.For<AppenderSkeleton>();
            //appender.When(a => a
            //.DoAppend(Arg.Any<LoggingEvent>()))
            //    .Do(c =>
            //    {
            //        var evt = c.Arg<LoggingEvent>();
            //    });

            //ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
            //BasicConfigurator.Configure(rep, appender);

            // Arrange
            var key   = "TestKey";
            var value = "Test Value";

            ThreadContext.Properties[key] = value;
            var message   = "Test message";
            var attribute = new RawPropertyLayoutAttribute(key);

            // Act
            var layout = sut.Adapt(attribute);

            var eventData = new LoggingEventData()
            {
                Message = message
            };
            var result = layout.Format(new LoggingEvent(eventData));

            // Assert
            Assert.AreEqual(value, result.ToString());
        }
Exemple #2
0
        public void GetLayout_WithRawPropertyLayoutAttribute_ShouldReturnRawPropertyLayout()
        {
            // Arrange
            var sut       = new LayoutAdapterProvider();
            var attribute = new RawPropertyLayoutAttribute("log4net:HostName");

            // Act
            var result = sut.GetLayout(attribute);

            // Assert
            Assert.IsInstanceOfType(result, typeof(RawPropertyLayout));
        }
        public void Adapt_WithLayoutAttribute_ShouldReturnIRawLayout()
        {
            // Arrange
            var             sut       = new RawPropertyLayoutAdapter();
            LayoutAttribute attribute = new RawPropertyLayoutAttribute("test");

            // Act
            var result = sut.Adapt(attribute);

            // Assert
            Assert.IsInstanceOfType(result, typeof(IRawLayout));
        }
        public void CanAdapt_WithValidType_ShouldReturnTrue()
        {
            // Arrange
            var sut       = new RawPropertyLayoutAdapter();
            var attribute = new RawPropertyLayoutAttribute("test");

            // Act
            var result = sut.CanAdapt(attribute);

            // Assert
            Assert.IsTrue(result);
        }
Exemple #5
0
        public void ConfigureLayout_WithAttribute_ShouldSetKey()
        {
            // Arrange
            var attribute = new RawPropertyLayoutAttribute("test");
            var layout    = new RawPropertyLayout();

            // Act
            sut.ConfigureLayout(layout, attribute);

            // Assert
            Assert.AreEqual(attribute.Key, layout.Key);
        }