public void IsBrowserDocumentRequest_ReturnsTrue_ForRequestsThatAcceptAnyHtml()
        {
            // Arrange
            var context = new DefaultHttpContext
            {
                Request =
                {
                    Method  = "Post",
                    Headers =
                    {
                        ["Accept"] = "application/json,text/*+html;q=0.9",
                    },
                },
            };

            // Act
            var result = BrowserRefreshMiddleware.IsBrowserDocumentRequest(context);

            // Assert
            Assert.True(result);
        }
        public void IsBrowserDocumentRequest_ReturnsFalse_IsRequestDoesNotAcceptHtml()
        {
            // Arrange
            var context = new DefaultHttpContext
            {
                Request =
                {
                    Method  = "GET",
                    Headers =
                    {
                        ["Accept"] = "application/xml",
                    },
                },
            };

            // Act
            var result = BrowserRefreshMiddleware.IsBrowserDocumentRequest(context);

            // Assert
            Assert.False(result);
        }
        public void IsBrowserDocumentRequest_ReturnsFalse_ForNonGetOrPostRequests(string method)
        {
            // Arrange
            var context = new DefaultHttpContext
            {
                Request =
                {
                    Method  = method,
                    Headers =
                    {
                        ["Accept"] = "application/html",
                    },
                },
            };

            // Act
            var result = BrowserRefreshMiddleware.IsBrowserDocumentRequest(context);

            // Assert
            Assert.False(result);
        }
        public void IsBrowserDocumentRequest_ReturnsTrue_IfRequestDoesNotHaveFetchMetadataRequestHeader()
        {
            // Arrange
            var context = new DefaultHttpContext
            {
                Request =
                {
                    Method  = "GET",
                    Headers =
                    {
                        ["Accept"] = "text/html",
                    },
                },
            };

            // Act
            var result = BrowserRefreshMiddleware.IsBrowserDocumentRequest(context);

            // Assert
            Assert.True(result);
        }
        public void IsBrowserDocumentRequest_ReturnsFalse_IfRequestFetchMetadataRequestHeaderIsNotDocument(string headerValue)
        {
            // Arrange
            var context = new DefaultHttpContext
            {
                Request =
                {
                    Method  = "Post",
                    Headers =
                    {
                        ["Accept"]         = "text/html",
                        ["Sec-Fetch-Dest"] = headerValue,
                    },
                },
            };

            // Act
            var result = BrowserRefreshMiddleware.IsBrowserDocumentRequest(context);

            // Assert
            Assert.False(result);
        }