public void Create_CreatesTemplateEngine_ForVersion1_1()
        {
            // Arrange
            var projectManager = new TestProjectSnapshotManager(Workspace);

            projectManager.ProjectAdded(Project);
            projectManager.ProjectUpdated(new ProjectSnapshotUpdateContext(Project)
            {
                Configuration = new MvcExtensibilityConfiguration(
                    RazorLanguageVersion.Version_1_1,
                    ProjectExtensibilityConfigurationKind.ApproximateMatch,
                    new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Mvc.Razor", new Version("1.1.3.0"))),
                    new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("1.1.3.0")))),
            });

            var factoryService = new DefaultProjectEngineFactoryService(projectManager);

            // Act
            var engine = factoryService.Create("/TestPath/SomePath/", b =>
            {
                b.Features.Add(new MyCoolNewFeature());
            });

            // Assert
            Assert.Single(engine.Engine.Features.OfType <MyCoolNewFeature>());
            Assert.Single(engine.Engine.Features.OfType <Mvc1_X.MvcViewDocumentClassifierPass>());
            Assert.Single(engine.Engine.Features.OfType <Mvc1_X.ViewComponentTagHelperPass>());
        }
        private RazorProjectEngineFactoryService GetTemplateEngineFactoryService()
        {
            var projectManager = new Mock <ProjectSnapshotManager>();

            projectManager.Setup(p => p.Projects).Returns(Array.Empty <ProjectSnapshot>());

            var service = new DefaultProjectEngineFactoryService(projectManager.Object);

            return(service);
        }
        public void Create_UnknownProjectPath_UsesLatest()
        {
            // Arrange
            var projectManager = new TestProjectSnapshotManager(Workspace);

            var factoryService = new DefaultProjectEngineFactoryService(projectManager);

            // Act
            var engine = factoryService.Create("/TestPath/DifferentPath/", b =>
            {
                b.Features.Add(new MyCoolNewFeature());
            });

            // Assert
            Assert.Single(engine.Engine.Features.OfType <MyCoolNewFeature>());
            Assert.Single(engine.Engine.Features.OfType <MvcLatest.MvcViewDocumentClassifierPass>());
            Assert.Single(engine.Engine.Features.OfType <MvcLatest.ViewComponentTagHelperPass>());
        }
Exemplo n.º 4
0
        private RazorProjectEngineFactoryService GetProjectEngineFactoryService()
        {
            var projectManager = new Mock <ProjectSnapshotManager>();

            projectManager.Setup(p => p.Projects).Returns(Array.Empty <ProjectSnapshot>());

            var projectEngineFactory = new Mock <IFallbackProjectEngineFactory>();

            projectEngineFactory.Setup(s => s.Create(It.IsAny <RazorConfiguration>(), It.IsAny <RazorProjectFileSystem>(), It.IsAny <Action <RazorProjectEngineBuilder> >()))
            .Returns <RazorConfiguration, RazorProjectFileSystem, Action <RazorProjectEngineBuilder> >(
                (c, fs, b) => RazorProjectEngine.Create(
                    RazorConfiguration.Default,
                    fs,
                    builder => RazorExtensions.Register(builder)));

            var service = new DefaultProjectEngineFactoryService(
                projectManager.Object,
                projectEngineFactory.Object,
                new Lazy <IProjectEngineFactory, ICustomProjectEngineFactoryMetadata> [0]);

            return(service);
        }
Exemplo n.º 5
0
        public void Create_DoesNotSupportViewComponentTagHelpers_ForVersion1_0()
        {
            // Arrange
            var projectManager = new TestProjectSnapshotManager(Workspace);

            projectManager.HostProjectAdded(HostProject_For_1_0);
            projectManager.WorkspaceProjectAdded(WorkspaceProject);

            var factoryService = new DefaultProjectEngineFactoryService(projectManager, FallbackFactory, CustomFactories);

            // Act
            var engine = factoryService.Create("/TestPath/SomePath/", b =>
            {
                b.Features.Add(new MyCoolNewFeature());
            });

            // Assert
            Assert.Single(engine.Engine.Features.OfType <MyCoolNewFeature>());
            Assert.Empty(engine.Engine.Features.OfType <MvcLatest.ViewComponentTagHelperDescriptorProvider>());
            Assert.Empty(engine.Engine.Features.OfType <MvcLatest.MvcViewDocumentClassifierPass>());
            Assert.Empty(engine.Engine.Features.OfType <MvcLatest.ViewComponentTagHelperPass>());
        }