public void IsAction_GenericMethod_FromUserDefinedController()
        {
            // Arrange
            var builder = new AccessibleActionModelBuilder();
            var method  = typeof(DerivedController).GetMethod("GenericMethod");

            Assert.NotNull(method);

            // Act
            var isValid = builder.IsAction(typeof(DerivedController).GetTypeInfo(), method);

            // Assert
            Assert.False(isValid);
        }
        public void IsAction_WithInheritedMethods(string methodName, bool expected)
        {
            // Arrange
            var builder = new AccessibleActionModelBuilder();
            var method  = typeof(DerivedController).GetMethod(methodName);

            Assert.NotNull(method);

            // Act
            var isValid = builder.IsAction(typeof(DerivedController).GetTypeInfo(), method);

            // Assert
            Assert.Equal(expected, isValid);
        }
        public void IsAction_OverridenMethodControllerClass()
        {
            // Arrange
            var builder = new AccessibleActionModelBuilder();
            var method  = typeof(BaseController).GetMethod(nameof(BaseController.Redirect));

            Assert.NotNull(method);

            // Act
            var isValid = builder.IsAction(typeof(BaseController).GetTypeInfo(), method);

            // Assert
            Assert.False(isValid);
        }
        public void IsAction_OperatorOverloadingMethod_FromOperatorOverloadingController()
        {
            // Arrange
            var builder = new AccessibleActionModelBuilder();
            var method  = typeof(OperatorOverloadingController).GetMethod("op_Addition");

            Assert.NotNull(method);
            Assert.True(method.IsSpecialName);

            // Act
            var isValid = builder.IsAction(typeof(OperatorOverloadingController).GetTypeInfo(), method);

            // Assert
            Assert.False(isValid);
        }
        public void IsAction_NewDisposeMethod()
        {
            // Arrange
            var builder  = new AccessibleActionModelBuilder();
            var typeInfo = typeof(DerivedNewDisposeController).GetTypeInfo();
            var method   = typeInfo.GetDeclaredMethods("Dispose").SingleOrDefault();

            Assert.NotNull(method);

            // Act
            var isValid = builder.IsAction(typeInfo, method);

            // Assert
            Assert.True(isValid);
        }
        public void IsAction_PrivateMethod_FromUserDefinedController()
        {
            // Arrange
            var builder = new AccessibleActionModelBuilder();
            var method  = typeof(DerivedController).GetMethod(
                "PrivateMethod",
                BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

            Assert.NotNull(method);

            // Act
            var isValid = builder.IsAction(typeof(DerivedController).GetTypeInfo(), method);

            // Assert
            Assert.False(isValid);
        }
        public void IsAction_StaticMethods(string methodName)
        {
            // Arrange
            var builder = new AccessibleActionModelBuilder();
            var method  = typeof(DerivedController).GetMethod(
                methodName,
                BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);

            Assert.NotNull(method);

            // Act
            var isValid = builder.IsAction(typeof(DerivedController).GetTypeInfo(), method);

            // Assert
            Assert.False(isValid);
        }
        public void IsAction_PocoControllerIDisposableDisposeMethod()
        {
            // Arrange
            var builder    = new AccessibleActionModelBuilder();
            var typeInfo   = typeof(IDisposablePocoController).GetTypeInfo();
            var methodInfo =
                typeInfo.GetRuntimeInterfaceMap(typeof(IDisposable)).TargetMethods[0];
            var method = typeInfo.GetMethods().Where(m => (m == methodInfo)).SingleOrDefault();

            Assert.NotNull(method);

            // Act
            var isValid = builder.IsAction(typeInfo, method);

            // Assert
            Assert.False(isValid);
        }
        public void IsAction_SimplePocoControllerDisposeMethod()
        {
            // Arrange
            var builder  = new AccessibleActionModelBuilder();
            var typeInfo = typeof(SimplePocoController).GetTypeInfo();
            var methods  = typeInfo.GetMethods().Where(m => m.Name.Equals("Dispose"));

            Assert.NotEmpty(methods);

            foreach (var method in methods)
            {
                // Act
                var isValid = builder.IsAction(typeInfo, method);

                // Assert
                Assert.True(isValid);
            }
        }
        public void IsAction_PocoControllerDisposeMethod()
        {
            // Arrange
            var builder    = new AccessibleActionModelBuilder();
            var typeInfo   = typeof(IDisposablePocoController).GetTypeInfo();
            var methodInfo =
                typeInfo.GetRuntimeInterfaceMap(typeof(IDisposable)).TargetMethods[0];
            var methods = typeInfo.GetMethods().Where(m => m.Name.Equals("Dispose") && m != methodInfo);

            Assert.NotEmpty(methods);

            foreach (var method in methods)
            {
                // Act
                var isValid = builder.IsAction(typeInfo, method);

                // Assert
                Assert.True(isValid);
            }
        }