コード例 #1
0
        /* ----------------------------------------------------------------- *
        * constructors                                                      *
        * ----------------------------------------------------------------- */

        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectController"/> class.
        /// </summary>
        /// <param name="configService">Injected Initializr configuration service.</param>
        /// <param name="projectGenerator">Injected project generator.</param>
        /// <param name="archiverRegistry">Injected archiver registry.</param>
        /// <param name="logger">Injected logger.</param>
        public ProjectController(
            IInitializrConfigService configService,
            IProjectGenerator projectGenerator,
            IArchiverRegistry archiverRegistry,
            ILogger <ProjectController> logger)
            : base(logger)
        {
            _configService    = configService;
            _projectGenerator = projectGenerator;
            _archiverRegistry = archiverRegistry;
        }
コード例 #2
0
            internal ProjectController Build()
            {
                if (_config is null)
                {
                    _config = new InitializrConfig
                    {
                        ProjectMetadata = new ProjectMetadata
                        {
                            Packaging = new ProjectMetadata.SingleSelectList
                            {
                                Default = "myarchive",
                            },
                        },
                        ProjectTemplates = new ProjectTemplateConfiguration[0],
                    };
                }

                if (_generator is null)
                {
                    _generator = new TestProjectGenerator();
                }

                if (_registry is null)
                {
                    var mock = new Mock <IArchiverRegistry>();
                    mock.Setup(reg => reg.Lookup(It.Is <string>(s => s.Equals("myarchive"))))
                    .Returns(new TestArchiver());
                    _registry = mock.Object;
                }

                var configurationService = new Mock <IInitializrConfigService>();

                configurationService.Setup(svc => svc.GetInitializrConfig()).Returns(_config);
                var logger            = new NullLogger <ProjectController>();
                var projectController =
                    new ProjectController(configurationService.Object, _generator, _registry, logger)
                {
                    ControllerContext =
                    {
                        HttpContext = new DefaultHttpContext()
                    }
                };

                return(projectController);
            }
コード例 #3
0
 internal ProjectControllerBuilder WithArchiverRegistry(IArchiverRegistry registry)
 {
     _registry = registry;
     return(this);
 }