public void TestUsePluginIdFromArchive() { CreatePlugin <ILogEntryParserPlugin>(new PluginId("Kittyfisto.Simon"), new Version(4, 3, 2), fakeId: new PluginId("Another.Plugin"), fakeVersion: new Version(2, 5, 42, 421)); CreatePlugin <ILogEntryParserPlugin>(new PluginId("Another.Plugin"), new Version(2, 4, 12)); using (var loader = new PluginArchiveLoader(_filesystem, Constants.PluginPath)) { var pluginsWithDescription = loader.LoadAllOfTypeWithDescription <ILogEntryParserPlugin>(); pluginsWithDescription.Should().HaveCount(2, "because there a two different plugins implementing that interface"); var plugin1 = pluginsWithDescription.FirstOrDefault(x => x.Description.Id == new PluginId("Another.Plugin")); plugin1.Should().NotBeNull(); plugin1.Description.Version.Should().Be(new Version(2, 4, 12)); var plugin2 = pluginsWithDescription.FirstOrDefault(x => x.Description.Id == new PluginId("Kittyfisto.Simon")); plugin2.Should().NotBeNull(); plugin2.Description.Version.Should().Be(new Version(4, 3, 2)); } }
public void TestLoadAllOfTypeWithDescription() { 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 <ILogEntryParserPlugin>("Plugin.FileFormatPlugin"); builder.Save(); packer.AddPluginAssembly(builder.FileName); } stream.Position = 0; var path = Path.Combine(Constants.PluginPath, "Kittyfisto.Simon.1.0.tvp"); _filesystem.WriteAllBytes(path, stream.ToArray()); using (var loader = new PluginArchiveLoader(_filesystem, Constants.PluginPath)) { var pluginsWithDescription = loader.LoadAllOfTypeWithDescription <ILogEntryParserPlugin>(); pluginsWithDescription.Should().HaveCount(1, "because we've added one plugin which implements the IFileFormatPlugin interface"); var description = pluginsWithDescription[0].Description; description.Should().NotBeNull(); description.Id.Should().Be(new PluginId("Kittyfisto.Simon")); description.Author.Should().Be("get of my lawn"); } } }
public void TestIgnoreIdenticalPlugin() { var id = new PluginId("Kittyfisto.Simon"); var version = new Version(4, 3, 2); CreatePlugin <ILogEntryParserPlugin>(Constants.PluginPath, id, version); CreatePlugin <ILogEntryParserPlugin>(Constants.DownloadedPluginsPath, id, version); using (var loader = new PluginArchiveLoader(_filesystem, new [] { Constants.PluginPath, Constants.DownloadedPluginsPath })) { var pluginsWithDescription = loader.LoadAllOfTypeWithDescription <ILogEntryParserPlugin>(); pluginsWithDescription.Should().HaveCount(1, "because only one instance of that plugin should've been loaded"); var plugin1 = pluginsWithDescription.FirstOrDefault(x => x.Description.Id == new PluginId("Kittyfisto.Simon")); plugin1.Should().NotBeNull(); plugin1.Description.Version.Should().Be(new Version(4, 3, 2)); } }