Beispiel #1
0
        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 AddGroup()
        {
            var repository = new PluginRepository();
            var definition = new GroupDefinition("a");

            var fileInfo = new PluginFileInfo("a", DateTimeOffset.Now);
            repository.AddGroup(definition, fileInfo);

            var groups = repository.Groups();
            Assert.AreEqual(1, groups.Count());
            Assert.AreSame(definition, groups.First());
            Assert.AreSame(definition, repository.Group(new GroupRegistrationId("a")));

            var files = repository.KnownPluginFiles();
            Assert.AreEqual(1, files.Count());
            Assert.AreSame(fileInfo, files.First());
        }
Beispiel #3
0
        public void AddGroup()
        {
            var repository = new PluginRepository();
            var definition = new GroupDefinition("a");

            var fileInfo = new PluginFileInfo("a", DateTimeOffset.Now);

            repository.AddGroup(definition, fileInfo);

            var groups = repository.Groups();

            Assert.AreEqual(1, groups.Count());
            Assert.AreSame(definition, groups.First());
            Assert.AreSame(definition, repository.Group(new GroupRegistrationId("a")));

            var files = repository.KnownPluginFiles();

            Assert.AreEqual(1, files.Count());
            Assert.AreSame(fileInfo, files.First());
        }
        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));
        }