public void AvailableExtensionsShouldFollowCatalogLocations() { var folders = new StubExtensionLocator(); folders.Manifests.Add("foo", "Name: Foo"); folders.Manifests.Add("bar", "Name: Bar"); folders.Manifests.Add("frap", "Name: Frap"); folders.Manifests.Add("quad", "Name: Quad"); var manager = new ExtensionManager(folders, new[] { new StubLoaders() }, new TypeFeatureProvider(), new NullLogger<ExtensionManager>()); var available = manager.AvailableExtensions(); Assert.Equal(4, available.Count()); Assert.True(available.Any(x => x.Id == "foo")); }
public void ExtensionDescriptorsShouldHaveNameAndVersion() { var folders = new StubExtensionLocator(); folders.Manifests.Add("Sample", @" Name: Sample Extension Version: 2.x "); var manager = new ExtensionManager(folders, new[] { new StubLoaders() }, new TypeFeatureProvider(), new NullLogger<ExtensionManager>()); var descriptor = manager.AvailableExtensions().Single(); Assert.Equal("Sample", descriptor.Id); Assert.Equal("Sample Extension", descriptor.Name); Assert.Equal("2.x", descriptor.Version); }
public void ExtensionDescriptorKeywordsAreCaseInsensitive() { var folders = new StubExtensionLocator(); folders.Manifests.Add("Sample", @" NaMe: Sample Extension SESSIONSTATE: disabled version: 2.x DESCRIPTION: HELLO "); var manager = new ExtensionManager(folders, new[] { new StubLoaders() }, new TypeFeatureProvider(), new NullLogger<ExtensionManager>()); var descriptor = manager.AvailableExtensions().Single(); Assert.Equal("Sample", descriptor.Id); Assert.Equal("Sample Extension", descriptor.Name); Assert.Equal("2.x", descriptor.Version); Assert.Equal("HELLO", descriptor.Description); Assert.Equal("disabled", descriptor.SessionState); }
public void ExtensionDescriptorsShouldBeParsedForCompleteModuleTxt() { var folders = new StubExtensionLocator(); folders.Manifests.Add("MyCompany.AnotherWiki", @" Name: AnotherWiki SessionState: required Author: Coder Notaprogrammer Website: http://anotherwiki.codeplex.com Version: 1.2.3 OrchardVersion: 1 Features: AnotherWiki: Description: My super wiki module for Orchard. Dependencies: Versioning, Search Category: Content types AnotherWiki Editor: Description: A rich editor for wiki contents. Dependencies: TinyMCE, AnotherWiki Category: Input methods AnotherWiki DistributionList: Description: Sends e-mail alerts when wiki contents gets published. Dependencies: AnotherWiki, Email Subscriptions Category: Email AnotherWiki Captcha: Description: Kills spam. Or makes it zombie-like. Dependencies: AnotherWiki, reCaptcha Category: Spam "); var manager = new ExtensionManager(folders, new[] { new StubLoaders() }, new TypeFeatureProvider(), new NullLogger<ExtensionManager>()); var descriptor = manager.AvailableExtensions().Single(); Assert.Equal("MyCompany.AnotherWiki", descriptor.Id); Assert.Equal("AnotherWiki", descriptor.Name); Assert.Equal("Coder Notaprogrammer", descriptor.Author); Assert.Equal("http://anotherwiki.codeplex.com", descriptor.WebSite); Assert.Equal("1.2.3", descriptor.Version); Assert.Equal("1", descriptor.OrchardVersion); Assert.Equal(5, descriptor.Features.Count()); Assert.Equal("required", descriptor.SessionState); foreach (var featureDescriptor in descriptor.Features) { switch (featureDescriptor.Id) { case "AnotherWiki": Assert.Same(descriptor, featureDescriptor.Extension); Assert.Equal("My super wiki module for Orchard.", featureDescriptor.Description); Assert.Equal("Content types", featureDescriptor.Category); Assert.Equal(2, featureDescriptor.Dependencies.Count()); Assert.Contains("Versioning", featureDescriptor.Dependencies); Assert.Contains("Search", featureDescriptor.Dependencies); break; case "AnotherWiki Editor": Assert.Same(descriptor, featureDescriptor.Extension); Assert.Equal("A rich editor for wiki contents.", featureDescriptor.Description); Assert.Equal("Input methods", featureDescriptor.Category); Assert.Equal(2, featureDescriptor.Dependencies.Count()); Assert.Contains("TinyMCE", featureDescriptor.Dependencies); Assert.Contains("AnotherWiki", featureDescriptor.Dependencies); break; case "AnotherWiki DistributionList": Assert.Same(descriptor, featureDescriptor.Extension); Assert.Equal("Sends e-mail alerts when wiki contents gets published.", featureDescriptor.Description); Assert.Equal("Email", featureDescriptor.Category); Assert.Equal(2, featureDescriptor.Dependencies.Count()); Assert.Contains("AnotherWiki", featureDescriptor.Dependencies); Assert.Contains("Email Subscriptions", featureDescriptor.Dependencies); break; case "AnotherWiki Captcha": Assert.Same(descriptor, featureDescriptor.Extension); Assert.Equal("Kills spam. Or makes it zombie-like.", featureDescriptor.Description); Assert.Equal("Spam", featureDescriptor.Category); Assert.Equal(2, featureDescriptor.Dependencies.Count()); Assert.Contains("AnotherWiki", featureDescriptor.Dependencies); Assert.Contains("reCaptcha", featureDescriptor.Dependencies); break; // default feature. case "MyCompany.AnotherWiki": Assert.Same(descriptor, featureDescriptor.Extension); break; default: throw new Exception("Features not parsed correctly"); } } }
public void ExtensionDescriptorsShouldBeParsedForMinimalModuleTxt() { var folders = new StubExtensionLocator(); folders.Manifests.Add("SuperWiki", @" Name: SuperWiki Version: 1.0.3 OrchardVersion: 1 Features: SuperWiki: Description: My super wiki module for Orchard. "); var manager = new ExtensionManager(folders, new[] { new StubLoaders() }, new TypeFeatureProvider(), new NullLogger<ExtensionManager>()); var descriptor = manager.AvailableExtensions().Single(); Assert.Equal("SuperWiki", descriptor.Id); Assert.Equal("1.0.3", descriptor.Version); Assert.Equal("1", descriptor.OrchardVersion); Assert.Equal(1, descriptor.Features.Count()); Assert.Equal("SuperWiki", descriptor.Features.First().Id); Assert.Equal("SuperWiki", descriptor.Features.First().Extension.Id); Assert.Equal("My super wiki module for Orchard.", descriptor.Features.First().Description); }
public void ModuleNameIsIntroducedAsFeatureImplicitly() { var extensionLoader = new StubLoaders(); var extensionFolder = new StubFolders(); extensionFolder.Manifests.Add("Minimalistic", @" name: Minimalistic version: 1.0.3 orchardversion: 1 "); IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }); var minimalisticModule = extensionManager.AvailableExtensions().Single(x => x.Name == "Minimalistic"); Assert.That(minimalisticModule.Features.Count(), Is.EqualTo(1)); Assert.That(minimalisticModule.Features.Single().Name, Is.EqualTo("Minimalistic")); }
public void ExtensionManagerLoadFeatureDoesNotReturnTypesFromNonMatchingFeatures() { var extensionLoader = new StubLoaders(); var extensionFolder = new StubFolders(); extensionFolder.Manifests.Add("TestModule", @" name: TestModule version: 1.0.3 orchardversion: 1 features: TestModule: Description: My test module for Orchard. TestFeature: Description: Contains the Phi type. "); IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }); var testModule = extensionManager.AvailableExtensions() .SelectMany(x => x.Features) .Single(x => x.Name == "TestModule"); foreach (var feature in extensionManager.LoadFeatures(new [] { testModule })) { foreach (var type in feature.ExportedTypes) { Assert.That(type != typeof(Phi)); Assert.That((type == typeof(Alpha) || (type == typeof(Beta)))); } } }
public void ExtensionManagerFeaturesContainNonAbstractClasses() { var extensionLoader = new StubLoaders(); var extensionFolder = new StubFolders(); extensionFolder.Manifests.Add("TestModule", @" name: TestModule version: 1.0.3 orchardversion: 1 features: TestModule: Description: My test module for Orchard. TestFeature: Description: Contains the Phi type. "); IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }); var testFeature = extensionManager.AvailableExtensions() .SelectMany(x => x.Features); var features = extensionManager.LoadFeatures(testFeature); var types = features.SelectMany(x => x.ExportedTypes); foreach (var type in types) { Assert.That(type.IsClass); Assert.That(!type.IsAbstract); } }
public void ExtensionManagerShouldLoadFeatures() { var extensionLoader = new StubLoaders(); var extensionFolder = new StubFolders(); extensionFolder.Manifests.Add("TestModule", @" name: TestModule version: 1.0.3 orchardversion: 1 features: TestModule: Description: My test module for Orchard. TestFeature: Description: Contains the Phi type. "); IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }); var testFeature = extensionManager.AvailableExtensions() .SelectMany(x => x.Features); var features = extensionManager.LoadFeatures(testFeature); var types = features.SelectMany(x => x.ExportedTypes); Assert.That(types.Count(), Is.Not.EqualTo(0)); }