BeginScope() public method

public BeginScope ( state ) : IDisposable
return IDisposable
        public void begin_scope_is_not_required_and_should_return_null()
        {
            // Arrange
            var logger = new Log4NetLogger("TestLogger");

            // Act
            var result = logger.BeginScope("Some data");

            // Assert
            result.Should().BeNull();
        }
        public void BeginScope_Should_Include_CustomScopeState_In_LoggedMessage()
        {
            const string CustomScope = "CustomScope";

            var mockedFactory = new Mock <ILog4NetScopeFactory>(MockBehavior.Default);

            mockedFactory.Setup(x => x.BeginScope(It.IsAny <string>()))
            .Returns(new Log4NetScope(CustomScope, new Log4NetScopeRegistry()));

            var options = ConfigureOptions(Log4NetFileOption.TestAppenderTrace);

            options.ScopeFactory = mockedFactory.Object;
            var testAppender = GetTestAppender(options);

            var sut = new Log4NetLogger(options);

            using (var scope = sut.BeginScope(CustomScope))
            {
                sut.Log(LogLevel.Critical, _eventId, _logState, null, (message, exception) => message);
            }

            sut.Log(LogLevel.Critical, _eventId, _logState, null, (message, exception) => message);

            // https://stackoverflow.com/questions/14438217/memoryappender-patternlayout-not-rendering
            testAppender.GetEvents()
            .Should()
            .NotBeEmpty()
            .And
            .HaveCount(2);
            testAppender.GetEvents()
            .First()
            .Level
            .Should()
            .Be(Level.Fatal);
            var textWriter = new StringWriter();

            testAppender.Layout.Format(textWriter, testAppender.GetEvents().First());
            textWriter.ToString()
            .Should()
            .Contain(_logState);
            textWriter.ToString()
            .Should()
            .Contain(CustomScope);

            textWriter.Close();
            textWriter = new StringWriter();
            testAppender.Layout.Format(textWriter, testAppender.GetEvents().Last());
            textWriter.ToString()
            .Should()
            .NotContain(CustomScope);
        }