Beispiel #1
0
        public void InitializeDocumentationLoadTest()
        {
            lock (_documentationLoadPlugin)
            {
                while (_pluginLoaded.HasValue && !_pluginLoaded.Value)
                {
                    System.Threading.Thread.Sleep(30);
                }

                if (_pluginLoaded.HasValue && _pluginLoaded.Value)
                {
                    return;
                }

                if (_pluginLoaded == null)
                {
                    _pluginLoaded = false;
                }

                _documentationLoadPlugin = new TestSearchPluginManager();
                _documentationLoadPlugin.AddAssembly(Assembly.GetExecutingAssembly());
                _documentationLoadPlugin.UsePlugin(typeof(DemoWebsite.Classes.PluginInitialisation));
                _documentationLoadPlugin.UsePlugin(typeof(DocumentationPlugin.PluginInitialisation));
                _documentationLoadPlugin.UsePlugin(typeof(MemoryCache.Plugin.PluginInitialisation));
                _documentationLoadPlugin.UsePlugin(typeof(ProductPlugin.PluginInitialisation));

                _documentationLoadPlugin.ConfigureServices();

                _pluginServices = new pm.PluginServices(_documentationLoadPlugin) as IPluginClassesService;
                TimeSpan docLoadTime   = new TimeSpan(0, 0, 30);
                DateTime startLoadDocs = DateTime.Now;

                while (Shared.Classes.ThreadManager.Exists(SharedPluginFeatures.Constants.DocumentationLoadThread))
                {
                    System.Threading.Thread.Sleep(100);

                    if (DateTime.Now - startLoadDocs > docLoadTime)
                    {
                        break;
                    }
                }

                Assert.IsFalse(Shared.Classes.ThreadManager.Exists(SharedPluginFeatures.Constants.DocumentationLoadThread));

                _documentationService = (IDocumentationService)_documentationLoadPlugin.GetServiceProvider()
                                        .GetService(typeof(IDocumentationService));

                Assert.IsNotNull(_documentationService);

                Assert.IsTrue(_documentationService.GetDocuments().Count > 100);
                _pluginLoaded = true;
            }

            Assert.IsNotNull(_pluginServices);
        }
Beispiel #2
0
        public void FindAllProvidersIncludingDocumentationPluginProvider()
        {
            using (TestSearchPluginManager pluginManager = new TestSearchPluginManager())
            {
                pluginManager.AddAssembly(Assembly.GetExecutingAssembly());
                IPluginClassesService pluginServices = new pm.PluginServices(pluginManager) as IPluginClassesService;

                Assert.IsNotNull(pluginServices);

                List <Type> classTypes = pluginServices.GetPluginClassTypes <ISearchKeywordProvider>();

                Assert.AreEqual(2, classTypes.Count);

                Assert.AreEqual("AspNetCore.PluginManager.Tests.Search.Mocks.MockKeywordSearchProviderA", classTypes[0].FullName);

                pluginManager.AddAssembly(typeof(DocumentationPlugin.PluginInitialisation).Assembly);

                classTypes = pluginServices.GetPluginClassTypes <ISearchKeywordProvider>();

                Assert.AreEqual(3, classTypes.Count);

                Assert.AreEqual("DocumentationPlugin.Classes.KeywordSearchProvider", classTypes[classTypes.Count - 1].FullName);
            }
        }
Beispiel #3
0
        public void KeywordSearchFindAllProviders()
        {
            using (TestSearchPluginManager pluginManager = new TestSearchPluginManager())
            {
                pluginManager.AddAssembly(Assembly.GetExecutingAssembly());
                IPluginClassesService pluginServices = new pm.PluginServices(pluginManager) as IPluginClassesService;

                Assert.IsNotNull(pluginServices);

                List <Type> classTypes = pluginServices.GetPluginClassTypes <ISearchKeywordProvider>();

                Assert.AreEqual(2, classTypes.Count);

                Assert.AreEqual("AspNetCore.PluginManager.Tests.Search.Mocks.MockKeywordSearchProviderA", classTypes[0].FullName);
            }
        }