public void TestLoadAllOfType1() { using (var stream = new MemoryStream()) { using (var packer = PluginPacker.Create(stream, true)) { var builder = new PluginBuilder("Kittyfisto", "SomePlugin", "none of your business", "get of my lawn"); builder.ImplementInterface <IFileFormatPlugin>("Plugin.FileFormatPlugin"); builder.Save(); packer.AddPluginAssembly(builder.FileName); } stream.Position = 0; using (var loader = new PluginArchiveLoader(null)) { var description = loader.ReflectPlugin(stream, true); var plugins = loader.LoadAllOfType <IFileFormatPlugin>()?.ToList(); plugins.Should().NotBeNull(); plugins.Should().HaveCount(1); plugins[0].Should().NotBeNull(); plugins[0].GetType().FullName.Should().Be("Plugin.FileFormatPlugin"); } } }
public void TestReflect1() { using (var stream = new MemoryStream()) { using (var packer = PluginPacker.Create(stream, true)) { var builder = new PluginBuilder("Kittyfisto", "UniquePluginId", "My very own plugin", "Simon", "http://google.com", "get of my lawn"); builder.ImplementInterface <IFileFormatPlugin>("Plugin.FileFormatPlugin"); builder.Save(); packer.AddPluginAssembly(builder.FileName); } stream.Position = 0; using (var loader = new PluginArchiveLoader(null)) { var description = loader.ReflectPlugin(stream, true); description.Should().NotBeNull(); description.Id.Should().Be(new PluginId("Kittyfisto.UniquePluginId")); description.Name.Should().Be("My very own plugin"); description.Version.Should().Be(new Version(0, 0, 0), "because the plugin version should default to 0.0.0 when none has been specified"); description.Author.Should().Be("Simon"); description.Website.Should().Be(new Uri("http://google.com")); description.Description.Should().Be("get of my lawn"); } } }
public void TestLoadDifferentVersions() { var plugin1 = CreatePlugin("Kittyfisto", "Foobar", new Version(1, 0)); var plugin2 = CreatePlugin("Kittyfisto", "Foobar", new Version(1, 1)); using (var loader = new PluginArchiveLoader(null)) { loader.ReflectPlugin(plugin1); loader.ReflectPlugin(plugin2); loader.Plugins.Should().HaveCount(1); loader.Plugins.First().Version.Should().Be(new Version(1, 1)); var plugins = loader.LoadAllOfType <IFileFormatPlugin>(); plugins.Should().HaveCount(1); } }
public void TestGetPluginStatusForInstalledPlugin() { using (var stream = new MemoryStream()) { CreatePlugin(stream); using (var loader = new PluginArchiveLoader(null)) { var description = loader.ReflectPlugin(stream, true); var status = loader.GetStatus(description); status.Should().NotBeNull(); status.IsInstalled.Should().BeTrue("because we've just installed that plugin"); status.IsLoaded.Should().BeFalse("because we haven't tried to load the plugin just yet"); status.LoadException.Should().BeNull("because we haven't tried to load the plugin just yet"); } } }
public void TestReflect2() { using (var loader = new PluginArchiveLoader(null)) { var description = loader.ReflectPlugin("C:\\BrokenPlugin.1.0.2.4.tvp"); description.Should().NotBeNull(); description.Author.Should().BeNull("because the author cannot be known"); description.Description.Should().BeNull("because we couldn't extract a description from the plugin"); description.FilePath.Should().Be("C:\\BrokenPlugin.1.0.2.4.tvp"); description.Id.Should().Be(new PluginId("BrokenPlugin"), "because the id should've been extracted from the path"); description.Error.Should().NotBeNull("because the plugin couldn't be loaded"); description.Plugins.Should().NotBeNull(); description.Plugins.Should().BeEmpty(); description.Version.Should().Be(new Version(1, 0, 2, 4), "because the version should've been extracted from the path"); description.Icon.Should().BeNull(); description.Website.Should().BeNull(); } }
public void TestLoad1() { using (var stream = new MemoryStream()) { using (var packer = PluginPacker.Create(stream, true)) { var builder = new PluginBuilder("Kittyfisto", "Simon", "none of your business", "get of my lawn"); builder.ImplementInterface <IFileFormatPlugin>("Plugin.FileFormatPlugin"); builder.Save(); packer.AddPluginAssembly(builder.FileName); } stream.Position = 0; using (var loader = new PluginArchiveLoader(null)) { var description = loader.ReflectPlugin(stream, true); var plugin = loader.Load <IFileFormatPlugin>(description); plugin.Should().NotBeNull(); } } }