public void GetParameterDefaultValues_ReturnsExpectedValues(string methodName, object[] expectedValues)
        {
            // Arrange
            var methodInfo = typeof(TestObject).GetMethod(methodName);

            // Act
            var actualValues = ParameterDefaultValues.GetParameterDefaultValues(methodInfo);

            // Assert
            Assert.Equal(expectedValues, actualValues);
        }
        public void GetParameterDefaultValues_ReturnsExpectedValues_ForStructTypes()
        {
            // Arrange
            var methodInfo = typeof(TestObject).GetMethod("DefaultValuesOfStructTypes");

            // Act
            var actualValues = ParameterDefaultValues.GetParameterDefaultValues(methodInfo);

            // Assert
            Assert.Equal(
                new object[] { default(Guid), default(TimeSpan), default(DateTime), default(DateTimeOffset) },
                actualValues);
        }
        public (ControllerActionInvokerCacheEntry cacheEntry, IFilterMetadata[] filters) GetCachedResult(ControllerContext controllerContext)
        {
            var cache            = CurrentCache;
            var actionDescriptor = controllerContext.ActionDescriptor;

            IFilterMetadata[] filters;
            if (!cache.Entries.TryGetValue(actionDescriptor, out var cacheEntry))
            {
                var filterFactoryResult = FilterFactory.GetAllFilters(_filterProviders, controllerContext);
                filters = filterFactoryResult.Filters;

                var parameterDefaultValues = ParameterDefaultValues
                                             .GetParameterDefaultValues(actionDescriptor.MethodInfo);

                var objectMethodExecutor = ObjectMethodExecutor.Create(
                    actionDescriptor.MethodInfo,
                    actionDescriptor.ControllerTypeInfo,
                    parameterDefaultValues);

                var controllerFactory     = _controllerFactoryProvider.CreateControllerFactory(actionDescriptor);
                var controllerReleaser    = _controllerFactoryProvider.CreateControllerReleaser(actionDescriptor);
                var propertyBinderFactory = ControllerBinderDelegateProvider.CreateBinderDelegate(
                    _parameterBinder,
                    _modelBinderFactory,
                    _modelMetadataProvider,
                    actionDescriptor,
                    _mvcOptions);

                var actionMethodExecutor = ActionMethodExecutor.GetExecutor(objectMethodExecutor);

                cacheEntry = new ControllerActionInvokerCacheEntry(
                    filterFactoryResult.CacheableFilters,
                    controllerFactory,
                    controllerReleaser,
                    propertyBinderFactory,
                    objectMethodExecutor,
                    actionMethodExecutor);
                cacheEntry = cache.Entries.GetOrAdd(actionDescriptor, cacheEntry);
            }
            else
            {
                // Filter instances from statically defined filter descriptors + from filter providers
                filters = FilterFactory.CreateUncachedFilters(_filterProviders, controllerContext, cacheEntry.CachedFilters);
            }

            return(cacheEntry, filters);
        }