public void WhenModelTypeNotAvailableThrowInvalidOperationException()
        {
            var mockHttpContext = new Mock <HttpContextBase>();

            var route = new RouteData();

            route.Values["action"] = "Detail";

            var mockController = new Mock <ControllerBase>();

            var mockFilterContext = new Mock <AuthorizationContext>();

            mockFilterContext.Expect(c => c.HttpContext).Returns(mockHttpContext.Object);
            mockFilterContext.Expect(c => c.Controller).Returns(mockController.Object);
            mockFilterContext.Expect(c => c.RouteData).Returns(route);

            var svc = new FinderAuthorizationService(null, AccessType.Read);

            svc.OnAuthorization(mockFilterContext.Object);
        }
        public void WhenModelTypeNotProvidedFindModelTypeIsCalled()
        {
            var mockHttpContext = new Mock <HttpContextBase>();

            var route = new RouteData();

            route.Values["action"] = "Detail";

            var mockController = new Mock <ControllerBase>();

            var mockFilterContext = new Mock <AuthorizationContext>();

            mockFilterContext.Expect(c => c.HttpContext).Returns(mockHttpContext.Object);
            mockFilterContext.Expect(c => c.Controller).Returns(mockController.Object);
            mockFilterContext.Expect(c => c.RouteData).Returns(route);

            var svc = new FinderAuthorizationService(typeof(string), AccessType.Read);

            svc.OnAuthorization(mockFilterContext.Object);

            Assert.IsTrue(svc.FindModelTypeIsCalled);
            Assert.AreEqual(typeof(string), svc.ModelType);
        }