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>());
        }
        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>());
        }
예제 #3
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>());
        }