コード例 #1
0
        private ControllerActionDescriptorProvider GetActionDescriptorProvider()
        {
            var assemblyProvider = new StaticAssemblyProvider();

            var controllerTypes = typeof(DefaultActionSelectorTests)
                                  .GetNestedTypes(BindingFlags.NonPublic)
                                  .Select(t => t.GetTypeInfo());

            var modelBuilder = new StaticControllerModelBuilder(controllerTypes.ToArray());

            return(new ControllerActionDescriptorProvider(
                       assemblyProvider,
                       modelBuilder,
                       new TestGlobalFilterProvider(),
                       new MockMvcOptionsAccessor()));
        }
コード例 #2
0
        private ControllerActionDescriptorProvider GetProvider(
            ILoggerFactory loggerFactory, params TypeInfo[] controllerTypeInfo)
        {
            var modelBuilder = new StaticControllerModelBuilder(controllerTypeInfo);

            var assemblyProvider = new Mock <IAssemblyProvider>();

            assemblyProvider
            .SetupGet(ap => ap.CandidateAssemblies)
            .Returns(new Assembly[] { controllerTypeInfo.First().Assembly });

            var provider = new ControllerActionDescriptorProvider(
                assemblyProvider.Object,
                modelBuilder,
                new TestGlobalFilterProvider(),
                new MockMvcOptionsAccessor(),
                loggerFactory);

            return(provider);
        }