public void RemovePluginsWithChildType() { var currentlyBuilding = new Dictionary <Type, TypeIdentity>(); var repository = new PluginRepository(); Func <Type, TypeIdentity> identityGenerator = TypeIdentityBuilder.IdentityFactory(repository, currentlyBuilding); PartDefinition parentDefinition = new PartDefinition { Identity = identityGenerator(typeof(MockExportingInterfaceImplementation)), }; var parentFileInfo = new PluginFileInfo("a", DateTimeOffset.Now); repository.AddPart(parentDefinition, parentFileInfo); PartDefinition childDefinition = new PartDefinition { Identity = identityGenerator(typeof(MockChildExportingInterfaceImplementation)), }; var childFileInfo = new PluginFileInfo("b", DateTimeOffset.Now); repository.AddPart(childDefinition, childFileInfo); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(MockExportingInterfaceImplementation)))); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(MockChildExportingInterfaceImplementation)))); Assert.IsTrue( repository.IsSubTypeOf( TypeIdentity.CreateDefinition(typeof(object)), TypeIdentity.CreateDefinition(typeof(MockChildExportingInterfaceImplementation)))); repository.RemovePlugins(new string[] { childFileInfo.Path }); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(MockExportingInterfaceImplementation)))); Assert.IsFalse(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(MockChildExportingInterfaceImplementation)))); }
public void RemovePlugins() { var currentlyBuilding = new Dictionary <Type, TypeIdentity>(); var repository = new PluginRepository(); Func <Type, TypeIdentity> identityGenerator = TypeIdentityBuilder.IdentityFactory(repository, currentlyBuilding); PartDefinition partDefinition = new PartDefinition { Identity = identityGenerator(typeof(ExportOnProperty)), }; var partFileInfo = new PluginFileInfo("a", DateTimeOffset.Now); repository.AddPart(partDefinition, partFileInfo); var groupDefinition = new GroupDefinition("b"); var groupFileInfo = new PluginFileInfo("c", DateTimeOffset.Now); repository.AddGroup(groupDefinition, groupFileInfo); Assert.That( repository.KnownPluginFiles(), Is.EquivalentTo( new List <PluginFileInfo> { partFileInfo, groupFileInfo, })); repository.RemovePlugins( new List <string> { partFileInfo.Path }); Assert.That( repository.KnownPluginFiles(), Is.EquivalentTo( new List <PluginFileInfo> { groupFileInfo, })); Assert.AreEqual(0, repository.Parts().Count()); Assert.AreEqual(1, repository.Groups().Count()); Assert.IsFalse(repository.ContainsDefinitionForType(typeof(ExportOnProperty).AssemblyQualifiedName)); }
public void RemovePluginsWithParentType() { var currentlyBuilding = new Dictionary<Type, TypeIdentity>(); var repository = new PluginRepository(); Func<Type, TypeIdentity> identityGenerator = TypeIdentityBuilder.IdentityFactory(repository, currentlyBuilding); PartDefinition parentDefinition = new PartDefinition { Identity = identityGenerator(typeof(MockExportingInterfaceImplementation)), }; var parentFileInfo = new PluginFileInfo("a", DateTimeOffset.Now); repository.AddPart(parentDefinition, parentFileInfo); PartDefinition childDefinition = new PartDefinition { Identity = identityGenerator(typeof(MockChildExportingInterfaceImplementation)), }; var childFileInfo = new PluginFileInfo("b", DateTimeOffset.Now); repository.AddPart(childDefinition, childFileInfo); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(MockExportingInterfaceImplementation)))); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(MockChildExportingInterfaceImplementation)))); Assert.IsTrue( repository.IsSubTypeOf( TypeIdentity.CreateDefinition(typeof(object)), TypeIdentity.CreateDefinition(typeof(MockChildExportingInterfaceImplementation)))); repository.RemovePlugins(new string[] { parentFileInfo.Path }); Assert.IsFalse(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(MockExportingInterfaceImplementation)))); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(MockChildExportingInterfaceImplementation)))); Assert.IsFalse( repository.IsSubTypeOf( TypeIdentity.CreateDefinition(typeof(object)), TypeIdentity.CreateDefinition(typeof(MockChildExportingInterfaceImplementation)))); }
public void RemovePlugins() { var currentlyBuilding = new Dictionary<Type, TypeIdentity>(); var repository = new PluginRepository(); Func<Type, TypeIdentity> identityGenerator = TypeIdentityBuilder.IdentityFactory(repository, currentlyBuilding); PartDefinition partDefinition = new PartDefinition { Identity = identityGenerator(typeof(ExportOnProperty)), }; var partFileInfo = new PluginFileInfo("a", DateTimeOffset.Now); repository.AddPart(partDefinition, partFileInfo); var groupDefinition = new GroupDefinition("b"); var groupFileInfo = new PluginFileInfo("c", DateTimeOffset.Now); repository.AddGroup(groupDefinition, groupFileInfo); Assert.That( repository.KnownPluginFiles(), Is.EquivalentTo( new List<PluginFileInfo> { partFileInfo, groupFileInfo, })); repository.RemovePlugins( new List<string> { partFileInfo.Path }); Assert.That( repository.KnownPluginFiles(), Is.EquivalentTo( new List<PluginFileInfo> { groupFileInfo, })); Assert.AreEqual(0, repository.Parts().Count()); Assert.AreEqual(1, repository.Groups().Count()); Assert.IsFalse(repository.ContainsDefinitionForType(typeof(ExportOnProperty).AssemblyQualifiedName)); }