public void Create_HeaderBlank_ReturnsDisposable()
        {
            // Arrange
            var          context = new CorrelatedLogContext();
            StringValues values  = new StringValues(string.Empty);
            var          headers = new Mock <IHeaderDictionary>(MockBehavior.Strict);

            headers.Setup(h => h.TryGetValue(It.IsAny <string>(), out values))
            .Returns(true);
            var httpRequest = new Mock <HttpRequest>(MockBehavior.Strict);

            httpRequest.Setup(r => r.Headers)
            .Returns(headers.Object);
            var httpContext = new Mock <HttpContext>(MockBehavior.Strict);

            httpContext.Setup(c => c.Request)
            .Returns(httpRequest.Object);

            // Act
            IDisposable disposable = context.InitializeFrom(httpContext.Object);

            // Verify
            Assert.IsNotNull(disposable);
            disposable.Dispose();
        }
        public void Create_NullContext_Throws()
        {
            var context = new CorrelatedLogContext();

            Assert.ThrowsException <ArgumentNullException>(
                () => context.InitializeFrom(null));
        }
        public void Create_NullRequest_Throws()
        {
            // Arrange
            var context     = new CorrelatedLogContext();
            var httpContext = new Mock <HttpContext>(MockBehavior.Strict);

            httpContext.Setup(c => c.Request)
            .Returns <HttpRequest>(null);

            // Act & Verify
            Assert.ThrowsException <ArgumentException>(
                () => context.InitializeFrom(httpContext.Object));
        }