public DefaultShapeTableManagerTests()
        {
            IServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging();
            serviceCollection.AddMemoryCache();
            serviceCollection.AddScoped <IFeatureManager, StubFeatureManager>();
            serviceCollection.AddScoped <IShapeTableManager, DefaultShapeTableManager>();
            serviceCollection.AddScoped <IEventBus, StubEventBus>();
            serviceCollection.AddSingleton <ITypeFeatureProvider, TypeFeatureProvider>();

            var theme1FeatureExtensionInfo       = new TestThemeExtensionInfo("Theme1");
            var baseThemeFeatureExtensionInfo    = new TestThemeExtensionInfo("BaseTheme");
            var derivedThemeFeatureExtensionInfo = new TestThemeExtensionInfo("DerivedTheme", baseThemeFeatureExtensionInfo.Features[0]);

            var features = new[] {
                theme1FeatureExtensionInfo.Features[0],
                derivedThemeFeatureExtensionInfo.Features[0],
                baseThemeFeatureExtensionInfo.Features[0]
            };

            serviceCollection.AddSingleton <IExtensionManager>(new TestExtensionManager(features));

            TestShapeProvider.FeatureShapes = new Dictionary <IFeatureInfo, IEnumerable <string> > {
                { TestFeature(), new [] { "Hello" } },
                { features[0], new [] { "Theme1Shape" } },
                { features[1], new [] { "DerivedShape", "OverriddenShape" } },
                { features[2], new [] { "BaseShape", "OverriddenShape" } }
            };

            serviceCollection.AddScoped <IShapeTableProvider, TestShapeProvider>();
            serviceCollection.AddScoped <TestShapeProvider>((x => (TestShapeProvider)x.GetService <IShapeTableProvider>()));

            _serviceProvider = serviceCollection.BuildServiceProvider();
        }
Пример #2
0
        public DefaultShapeTableManagerTests()
        {
            IServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging();
            serviceCollection.AddMemoryCache();
            serviceCollection.AddScoped <IShellFeaturesManager, TestShellFeaturesManager>();
            serviceCollection.AddScoped <IShapeTableManager, DefaultShapeTableManager>();
            serviceCollection.AddScoped <IEventBus, StubEventBus>();
            serviceCollection.AddSingleton <ITypeFeatureProvider, TypeFeatureProvider>();
            serviceCollection.AddSingleton <IExtensionOrderingStrategy, ThemeExtensionOrderingStrategy>();

            var testFeatureExtensionInfo         = new TestModuleExtensionInfo("Testing");
            var theme1FeatureExtensionInfo       = new TestThemeExtensionInfo("Theme1");
            var baseThemeFeatureExtensionInfo    = new TestThemeExtensionInfo("BaseTheme");
            var derivedThemeFeatureExtensionInfo = new TestThemeExtensionInfo("DerivedTheme", baseThemeFeatureExtensionInfo.Features.First());

            var features = new[] {
                testFeatureExtensionInfo.Features.First(),
                theme1FeatureExtensionInfo.Features.First(),
                baseThemeFeatureExtensionInfo.Features.First(),
                derivedThemeFeatureExtensionInfo.Features.First()
            };

            serviceCollection.AddSingleton <IExtensionManager>(new TestExtensionManager(features));

            TestShapeProvider.FeatureShapes = new Dictionary <IFeatureInfo, IEnumerable <string> > {
                { TestFeature(), new [] { "Hello" } },
                { features[1], new [] { "Theme1Shape" } },
                { features[2], new [] { "DerivedShape", "OverriddenShape" } },
                { features[3], new [] { "BaseShape", "OverriddenShape" } }
            };

            serviceCollection.AddScoped <IShapeTableProvider, TestShapeProvider>();
            serviceCollection.AddScoped <TestShapeProvider>((x => (TestShapeProvider)x.GetService <IShapeTableProvider>()));

            _serviceProvider = serviceCollection.BuildServiceProvider();

            var typeFeatureProvider = _serviceProvider.GetService <ITypeFeatureProvider>();

            typeFeatureProvider.TryAdd(typeof(TestShapeProvider), new InternalFeatureInfo("Core", new InternalExtensionInfo("Core")));
        }