public void GetMainPageTest() { //Arrange PluginResolver pluginResolver = new PluginResolver(); pluginResolver.AddPlugin(typeof(TestPlugin.TestPlugin), "TestKey"); pluginResolver.LoadPluginPageComponent(typeof(TestPageComponent)); pluginResolver.LoadPluginPageComponent(typeof(MainTestPageComponent)); //Act var mainPage = pluginResolver.GetMainPage(typeof(TestPlugin.TestPlugin)); //Assert Assert.NotNull(mainPage); Assert.Equal(typeof(MainTestPageComponent), mainPage.GetType()); }
public IEnumerable <PluginPageComponent> LoadPages(Assembly assembly) { var pageTypes = assembly.GetTypes().Where(type => type.BaseType == typeof(PluginPageComponent)).ToList(); foreach (Type pageType in pageTypes) { yield return(_pluginResolver.LoadPluginPageComponent(pageType)); } }
public void GetPageComponentsTest() { //Arrange PluginResolver pluginResolver = new PluginResolver(); pluginResolver.AddPlugin(typeof(TestPlugin.TestPlugin), "TestKey"); pluginResolver.LoadPluginPageComponent(typeof(TestPageComponent)); pluginResolver.LoadPluginPageComponent(typeof(MainTestPageComponent)); //Act var pageComponents = pluginResolver.GetPageComponents().ToList(); //Assert Assert.NotNull(pageComponents); Assert.Equal(2, pageComponents.Count); Assert.Equal("TestKey", pageComponents[0].PluginKey); Assert.Equal("TestKey", pageComponents[1].PluginKey); Assert.True(pageComponents[1].IsMainPage); }
public void LoadPluginPageComponentTest() { //Arrange PluginResolver pluginResolver = new PluginResolver(); pluginResolver.AddPlugin(typeof(TestPlugin.TestPlugin), "TestKey"); //Act pluginResolver.LoadPluginPageComponent(typeof(TestPageComponent)); //Assert var plugin = pluginResolver.GetPlugin(typeof(TestPlugin.TestPlugin)); Assert.Single(plugin.PluginPages); Assert.True(plugin.PluginPages.ContainsKey("/test")); //make sure the page component is not null Assert.NotNull(plugin.PluginPages["/test"].Item2); //we only load the component so the IPage SHOULD be null Assert.Null(plugin.PluginPages["/test"].Item1); Assert.Equal("TestKey", plugin.PluginPages["/test"].Item2.PluginKey); }
public void SetPluginPageComponentTest() { //Arrange PluginResolver pluginResolver = new PluginResolver(); pluginResolver.AddPlugin(typeof(TestPlugin.TestPlugin), "TestKey"); pluginResolver.LoadPluginPageComponent(typeof(TestPageComponent)); var oldComponent = pluginResolver.GetPageComponents().First(); oldComponent.Data = new PluginData(); oldComponent.PluginSettings = new PluginData(); var newComponent = new TestPageComponent(); //Act pluginResolver.SetPluginPageComponent(newComponent); //Assert Assert.NotEqual(oldComponent, pluginResolver.GetPageComponents().First()); Assert.Equal("TestKey", newComponent.PluginKey); Assert.NotNull(newComponent.Data); Assert.NotNull(newComponent.PluginSettings); }