public void Should_throw_when_exception_is_null()
        {
            // Arrange
            PolicyViolationException exception = null;
            var handler = new HttpUnauthorizedPolicyViolationHandler();

            // Act & Assert
            Assert.Throws<ArgumentNullException>(() => handler.Handle(exception));
        }
        public void Should_throw_when_exception_is_null()
        {
            // Arrange
            PolicyViolationException exception = null;
            var handler = new HttpUnauthorizedPolicyViolationHandler();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => handler.Handle(exception));
        }
        public void Should_return_HttpUnauthorizedResult()
        {
            // Arrange
            var policyResult = TestDataFactory.CreatePolicyResultFailure();
            var exception    = TestDataFactory.CreatePolicyViolationException(policyResult);
            var handler      = new HttpUnauthorizedPolicyViolationHandler();

            // Act
            var result = handler.Handle(exception).As <HttpUnauthorizedResult>();

            // Assert
            Assert.That(result.StatusCode, Is.EqualTo((int)HttpStatusCode.Unauthorized));
            Assert.That(result.StatusDescription, Is.EqualTo(exception.Message));
        }
        public void Should_return_HttpUnauthorizedResult()
        {
            // Arrange
            var policyResult = TestDataFactory.CreatePolicyResultFailure();
            var exception = TestDataFactory.CreatePolicyViolationException(policyResult);
            var handler = new HttpUnauthorizedPolicyViolationHandler();

            // Act
            var result = handler.Handle(exception).As<HttpUnauthorizedResult>();

            // Assert
            Assert.That(result.StatusCode, Is.EqualTo((int)HttpStatusCode.Unauthorized));
            Assert.That(result.StatusDescription, Is.EqualTo(exception.Message));
        }