public void OnAuthorization_ShouldThrowInvalidOperactoinException_WhenTempDataDoesNotContainHoneypotKey()
        {
            AuthorizationContext filterContext = new Mock <AuthorizationContext> {
                DefaultValue = DefaultValue.Mock
            }.Object;
            var attribue = new HoneypotAttribute();

            Assert.Throws <InvalidOperationException>(() => attribue.OnAuthorization(filterContext));
        }
        public void OnAuthorization_ShouldReturn_WhenHoneypotKeyIsNotInTempData()
        {
            var filterContext = MvcHelper.GetAuthorizationContext();
            var attribue      = new HoneypotAttribute();

            attribue.OnAuthorization(filterContext);

            Assert.Null(filterContext.Result);
        }
        public void OnAuthorization_ShouldRedirectToProvidedUrl_WhenTempDataKeyHasValue()
        {
            var filterContext = MvcHelper.GetAuthorizationContext(_from);
            var attribue      = new HoneypotAttribute("/Handle/Bot");

            attribue.OnAuthorization(filterContext);

            Assert.Equal("RedirectResult", filterContext.Result.GetType().Name);
            var result = (RedirectResult)filterContext.Result;

            Assert.Equal("/Handle/Bot", result.Url);
        }
        public void OnAuthorization_ShouldThrowArgumentNullException_WhenFilterContextIsNull()
        {
            var attribue = new HoneypotAttribute();

            Assert.Throws <ArgumentNullException>(() => attribue.OnAuthorization(null));
        }