本文整理汇总了C#中StubFolders类的典型用法代码示例。如果您正苦于以下问题:C# StubFolders类的具体用法?C# StubFolders怎么用?C# StubFolders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StubFolders类属于命名空间,在下文中一共展示了StubFolders类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init(IEnumerable<Type> dataMigrations) {
var builder = new ContainerBuilder();
_folders = new StubFolders();
var contentDefinitionManager = new Mock<IContentDefinitionManager>().Object;
builder.RegisterInstance(new ShellSettings { DataTablePrefix = "TEST_"});
builder.RegisterType<SqlServerDataServicesProvider>().As<IDataServicesProvider>();
builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>();
builder.RegisterType<NullInterpreter>().As<IDataMigrationInterpreter>();
builder.RegisterInstance(_folders).As<IExtensionFolders>();
builder.RegisterInstance(contentDefinitionManager).As<IContentDefinitionManager>();
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
builder.RegisterType<DataMigrationManager>().As<IDataMigrationManager>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>().As<ITransactionManager>();
foreach(var type in dataMigrations) {
builder.RegisterType(type).As<IDataMigration>();
}
_container = builder.Build();
_container.Resolve<IExtensionManager>();
_dataMigrationManager = _container.Resolve<IDataMigrationManager>();
_repository = _container.Resolve<IRepository<DataMigrationRecord>>();
_transactionManager = _container.Resolve<ITransactionManager>();
InitDb();
}
示例2: Init
public void Init() {
var builder = new ContainerBuilder();
_folders = new StubFolders();
builder.RegisterInstance(_folders).As<IExtensionFolders>();
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
_container = builder.Build();
_manager = _container.Resolve<IExtensionManager>();
}
示例3: Init
public void Init() {
var builder = new ContainerBuilder();
_folders = new StubFolders(DefaultExtensionTypes.Module);
builder.RegisterInstance(_folders).As<IExtensionFolders>();
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
_container = builder.Build();
_manager = _container.Resolve<IExtensionManager>();
}
示例4: FeatureDescriptorsShouldBeLoadedInThemes
public void FeatureDescriptorsShouldBeLoadedInThemes()
{
var extensionLoader = new StubLoaders();
var moduleExtensionFolder = new StubFolders();
var themeExtensionFolder = new StubFolders(DefaultExtensionTypes.Theme);
moduleExtensionFolder.Manifests.Add("Alpha", @"
Name: Alpha
Version: 1.0.3
CoeveryVersion: 1
Features:
Alpha:
Dependencies: Gamma
");
moduleExtensionFolder.Manifests.Add("Beta", @"
Name: Beta
Version: 1.0.3
CoeveryVersion: 1
");
moduleExtensionFolder.Manifests.Add("Gamma", @"
Name: Gamma
Version: 1.0.3
CoeveryVersion: 1
Features:
Gamma:
Dependencies: Beta
");
moduleExtensionFolder.Manifests.Add("Classic", @"
Name: Classic
Version: 1.0.3
CoeveryVersion: 1
");
IExtensionManager extensionManager = CreateExtensionManager(new[] { moduleExtensionFolder, themeExtensionFolder }, new[] { extensionLoader });
var features = extensionManager.AvailableFeatures();
Assert.That(features.Count(), Is.EqualTo(4));
}
示例5: FeatureDescriptorsAreInPriorityOrder
public void FeatureDescriptorsAreInPriorityOrder()
{
var extensionLoader = new StubLoaders();
var extensionFolder = new StubFolders();
// Check that priorities apply correctly on items on the same level of dependencies and are overwritten by dependencies
extensionFolder.Manifests.Add("Alpha", CreateManifest("Alpha", "4")); // More important than Gamma but will get overwritten by the dependency
extensionFolder.Manifests.Add("Beta", CreateManifest("Beta", "3"));
extensionFolder.Manifests.Add("Foo", CreateManifest("Foo", "1"));
extensionFolder.Manifests.Add("Gamma", CreateManifest("Gamma", "2"));
AssertFeaturesAreInOrder(extensionFolder, extensionLoader, "<Foo<Gamma<Beta<Alpha<");
}
示例6: FeatureDescriptorsAreInManifestOrderWhenTheyHaveEqualPriority
public void FeatureDescriptorsAreInManifestOrderWhenTheyHaveEqualPriority()
{
var extensionLoader = new StubLoaders();
var extensionFolder = new StubFolders();
extensionFolder.Manifests.Add("Alpha", CreateManifest("Alpha", "4"));
extensionFolder.Manifests.Add("Beta", CreateManifest("Beta", "4"));
extensionFolder.Manifests.Add("Gamma", CreateManifest("Gamma", "4"));
extensionFolder.Manifests.Add("Foo", CreateManifest("Foo", "3"));
extensionFolder.Manifests.Add("Bar", CreateManifest("Bar", "3"));
extensionFolder.Manifests.Add("Baz", CreateManifest("Baz", "3"));
AssertFeaturesAreInOrder(extensionFolder, extensionLoader, "<Foo<Bar<Baz<Alpha<Beta<Gamma<");
}
示例7: FeatureDescriptorsAreInDependencyOrder
public void FeatureDescriptorsAreInDependencyOrder()
{
var extensionLoader = new StubLoaders();
var extensionFolder = new StubFolders();
extensionFolder.Manifests.Add("Alpha", @"
Name: Alpha
Version: 1.0.3
CoeveryVersion: 1
Features:
Alpha:
Dependencies: Gamma
");
extensionFolder.Manifests.Add("Beta", @"
Name: Beta
Version: 1.0.3
CoeveryVersion: 1
");
extensionFolder.Manifests.Add("Gamma", @"
Name: Gamma
Version: 1.0.3
CoeveryVersion: 1
Features:
Gamma:
Dependencies: Beta
");
IExtensionManager extensionManager = CreateExtensionManager(extensionFolder, extensionLoader);
var features = extensionManager.AvailableFeatures();
Assert.That(features.Aggregate("<", (a, b) => a + b.Id + "<"), Is.EqualTo("<Beta<Gamma<Alpha<"));
}
示例8: FeatureDescriptorsAreInDependencyAndPriorityOrder
public void FeatureDescriptorsAreInDependencyAndPriorityOrder()
{
var extensionLoader = new StubLoaders();
var extensionFolder = new StubFolders();
// Check that priorities apply correctly on items on the same level of dependencies and are overwritten by dependencies
extensionFolder.Manifests.Add("Alpha", CreateManifest("Alpha", "2", "Gamma")); // More important than Gamma but will get overwritten by the dependency
extensionFolder.Manifests.Add("Beta", CreateManifest("Beta", "2"));
extensionFolder.Manifests.Add("Foo", CreateManifest("Foo", "1"));
extensionFolder.Manifests.Add("Gamma", CreateManifest("Gamma", "3", "Beta, Foo"));
AssertFeaturesAreInOrder(extensionFolder, extensionLoader, "<Foo<Beta<Gamma<Alpha<");
// Change priorities and see that it reflects properly
// Gamma comes after Foo (same priority) because their order in the Manifests is preserved
extensionFolder.Manifests["Foo"] = CreateManifest("Foo", "3");
AssertFeaturesAreInOrder(extensionFolder, extensionLoader, "<Beta<Foo<Gamma<Alpha<");
// Remove dependency on Foo and see that it moves down the list since no one depends on it anymore
extensionFolder.Manifests["Gamma"] = CreateManifest("Gamma", "3", "Beta");
AssertFeaturesAreInOrder(extensionFolder, extensionLoader, "<Beta<Gamma<Alpha<Foo<");
// Change Foo to depend on Gamma and see that it says in its position (same dependencies as alpha but lower priority)
extensionFolder.Manifests["Foo"] = CreateManifest("Foo", "3", "Gamma");
AssertFeaturesAreInOrder(extensionFolder, extensionLoader, "<Beta<Gamma<Alpha<Foo<");
// Update Foo to a higher priority than alpha and see that it moves before alpha
extensionFolder.Manifests["Foo"] = CreateManifest("Foo", "1", "Gamma");
AssertFeaturesAreInOrder(extensionFolder, extensionLoader, "<Beta<Gamma<Foo<Alpha<");
}
示例9: ModuleNameIsIntroducedAsFeatureImplicitly
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"));
}
示例10: AssertFeaturesAreInOrder
private static void AssertFeaturesAreInOrder(StubFolders folder, StubLoaders loader, string expectedOrder)
{
AssertFeaturesAreInOrder(new StubFolders[] { folder }, loader, expectedOrder);
}
示例11: ExtensionManagerLoadFeatureReturnsTypesFromSpecificFeaturesWithFeatureAttribute
public void ExtensionManagerLoadFeatureReturnsTypesFromSpecificFeaturesWithFeatureAttribute()
{
var extensionLoader = new StubLoaders();
var extensionFolder = new StubFolders();
extensionFolder.Manifests.Add("TestModule", @"
Name: TestModule
Version: 1.0.3
CoeveryVersion: 1
Features:
TestModule:
Description: My test module for Coevery.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = CreateExtensionManager(extensionFolder, extensionLoader);
var testFeature = extensionManager.AvailableExtensions()
.SelectMany(x => x.Features)
.Single(x => x.Id == "TestFeature");
foreach (var feature in extensionManager.LoadFeatures(new[] { testFeature })) {
foreach (var type in feature.ExportedTypes) {
Assert.That(type == typeof(Phi));
}
}
}
示例12: ExtensionManagerFeaturesContainNonAbstractClasses
public void ExtensionManagerFeaturesContainNonAbstractClasses()
{
var extensionLoader = new StubLoaders();
var extensionFolder = new StubFolders();
extensionFolder.Manifests.Add("TestModule", @"
Name: TestModule
Version: 1.0.3
CoeveryVersion: 1
Features:
TestModule:
Description: My test module for Coevery.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = CreateExtensionManager(extensionFolder, 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);
}
}
示例13: CreateDb
public void CreateDb() {
var types = new[] {
typeof(BlogRecord),
typeof(BodyRecord),
typeof(BlogArchiveRecord),
typeof(ContentItemVersionRecord),
typeof(ContentItemRecord),
typeof(ContentTypeRecord)};
_tempFolderName = _tempFixtureFolderName.Combine(System.IO.Path.GetRandomFileName());
try {
_tempFixtureFolderName.Delete(true);
} catch {}
_tempFixtureFolderName.CreateDirectory();
_sessionFactory = DataUtility.CreateSessionFactory(
_tempFolderName, types);
var builder = new ContainerBuilder();
_folders = new StubFolders();
var manager = (IDataServicesProviderFactory)new DataServicesProviderFactory(new[] {
new Meta<CreateDataServicesProvider>(
(dataFolder, connectionString) => new SqlCeDataServicesProvider(dataFolder, connectionString),
new Dictionary<string, object> {{"ProviderName", "SqlCe"}})
});
builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataTablePrefix = "TEST", DataProvider = "SqlCe" });
builder.RegisterInstance(AppDataFolderTests.CreateAppDataFolder(_tempFixtureFolderName)).As<IAppDataFolder>();
builder.RegisterType<SessionConfigurationCache>().As<ISessionConfigurationCache>();
builder.RegisterType<SqlCeDataServicesProvider>().As<IDataServicesProvider>();
builder.RegisterInstance(manager).As<IDataServicesProviderFactory>();
builder.RegisterType<NullInterpreter>().As<IDataMigrationInterpreter>();
builder.RegisterType<SessionFactoryHolder>().As<ISessionFactoryHolder>();
builder.RegisterType<CompositionStrategy>().As<ICompositionStrategy>();
builder.RegisterInstance(_folders).As<IExtensionFolders>();
builder.RegisterType<StubLoaders>().As<IExtensionLoader>();
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
builder.RegisterType<SchemaCommandGenerator>().As<ISchemaCommandGenerator>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(new ShellBlueprint());
_container = builder.Build();
_generator = _container.Resolve<ISchemaCommandGenerator>();
_folders.Manifests.Add("Feature1", @"
Name: Module1
Version: 0.1
OrchardVersion: 1
Features:
Feature1:
Description: Feature
");
}
示例14: ExtensionManagerLoadFeatureDoesNotReturnTypesFromNonMatchingFeatures
public void ExtensionManagerLoadFeatureDoesNotReturnTypesFromNonMatchingFeatures() {
var extensionLoader = new StubLoaders();
var extensionFolder = new StubFolders(DefaultExtensionTypes.Module);
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 = CreateExtensionManager(extensionFolder, extensionLoader);
var testModule = extensionManager.AvailableExtensions()
.SelectMany(x => x.Features)
.Single(x => x.Id == "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))));
}
}
}
示例15: CreateExtensionManager
private ExtensionManager CreateExtensionManager(StubFolders extensionFolder, StubLoaders extensionLoader) {
return new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager(), new StubParallelCacheContext(), new StubAsyncTokenProvider());
}