Exemplo n.º 1
0
        public void TestDiscoverOnePlugin()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();

            TestBase.CopyPluginToTestDir( "ServiceA.dll" );

            discoverer.Discover( TestBase.TestFolderDir, true );

            Assert.That( discoverer.AllAssemblies.Count == 1 );
            Assert.That( discoverer.PluginOrServiceAssemblies.Count == 1 );
            Assert.That( discoverer.Plugins.Count == 1 );
            Assert.That( discoverer.Services.Count == 1 );

            //Test methods, events and properties info :
            IReadOnlyCollection<ISimpleEventInfo> events = discoverer.Services.First().EventsInfoCollection;
            IReadOnlyCollection<ISimpleMethodInfo> methods = discoverer.Services.First().MethodsInfoCollection;
            IReadOnlyCollection<ISimplePropertyInfo> properties = discoverer.Services.First().PropertiesInfoCollection;

            Assert.That( events.Count, Is.EqualTo( 1 ) );
            Assert.That( methods.Count, Is.EqualTo( 2 ) );
            Assert.That( properties.Count, Is.EqualTo( 1 ) );

            Assert.That( events.First().Name, Is.EqualTo( "HasStarted" ) );

            Assert.That( methods.First().Name, Is.EqualTo( "Add" ) );
            Assert.That( methods.First().Parameters.Count, Is.EqualTo( 2 ) );
            Assert.That( methods.First().Parameters.First().ParameterName, Is.EqualTo( "a" ) );
            Assert.That( methods.First().Parameters.Last().ParameterName, Is.EqualTo( "b" ) );
            Assert.That( methods.First().ReturnType, Is.EqualTo( "System.Int32" ) );

            Assert.That( properties.First().Name, Is.EqualTo( "HasBeenStarted" ) );
            Assert.That( properties.First().PropertyType, Is.EqualTo( "System.Boolean" ) );
        }
Exemplo n.º 2
0
        public void TestDiscoverEditors()
        {
            int nbEditors = 0;

            PluginDiscoverer discoverer = new PluginDiscoverer();

            TestBase.CopyPluginToTestDir("ServiceA.dll");
            TestBase.CopyPluginToTestDir("ServiceB.dll");
            TestBase.CopyPluginToTestDir("EditorsOfPlugins.dll");
            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(discoverer.AllAssemblies.Count == 3);
            Assert.That(discoverer.PluginOrServiceAssemblies.Count == 3);
            Assert.That(discoverer.Plugins.Count, Is.EqualTo(6));

            foreach (IPluginInfo plugin in discoverer.Plugins)
            {
                nbEditors += plugin.EditorsInfo.Count;
            }

            Assert.That(nbEditors, Is.EqualTo(6));     // 6 because ServiceA get an accessor to its configuration.

            IPluginInfo editorOfTwoPlugins = discoverer.FindPlugin(new Guid("{BC7E641B-E4EE-47f5-833B-0AFFFAA2A683}"));

            Assert.That(editorOfTwoPlugins.EditorsInfo.Any((a) => { return((a.ConfigurationPropertyName == "ConfigPlugin01") && (a.IsConfigurationPropertyValid)); }));
            Assert.That(editorOfTwoPlugins.EditorsInfo.Any((a) => { return((a.ConfigurationPropertyName == "ConfigPlugin02") && (a.IsConfigurationPropertyValid)); }));
        }
Exemplo n.º 3
0
        public void AddRemovePluginsAndService()
        {
            DiscoverDoneEventArgs lastDiscoverEventArgs = null;

            PluginDiscoverer discoverer = new PluginDiscoverer();

            discoverer.DiscoverDone += (sender, e) => lastDiscoverEventArgs = e;

            // Add 2 assemblies : 2 plugins & 2 services
            TestBase.CopyPluginToTestDir("ServiceA.dll");
            TestBase.CopyPluginToTestDir("ServiceB.dll");

            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(lastDiscoverEventArgs.NewPlugins.Count, Is.EqualTo(2));
            Assert.That(lastDiscoverEventArgs.NewServices.Count, Is.EqualTo(2));

            // Clear and add previous plugins, and add a new service
            TestBase.CleanupTestDir();
            TestBase.CopyPluginToTestDir("ServiceA.dll");
            TestBase.CopyPluginToTestDir("ServiceC.Model.dll");

            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(lastDiscoverEventArgs.NewPlugins.Count, Is.EqualTo(0));
            Assert.That(lastDiscoverEventArgs.NewServices.Count, Is.EqualTo(1));
            Assert.That(lastDiscoverEventArgs.DeletedServices.Count, Is.EqualTo(1));
            Assert.That(lastDiscoverEventArgs.DeletedPlugins.Count, Is.EqualTo(1));
        }
Exemplo n.º 4
0
        public async Task DiscoverAsync_PerformsDiscoveryOnlyOnce()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var pluginPath = Path.Combine(testDirectory.Path, "a");

                File.WriteAllText(pluginPath, string.Empty);

                var responses = new Dictionary <string, bool>()
                {
                    { pluginPath, true }
                };
                var verifierStub = new EmbeddedSignatureVerifierStub(responses);

                using (var discoverer = new PluginDiscoverer(pluginPath, verifierStub))
                {
                    var results = (await discoverer.DiscoverAsync(CancellationToken.None)).ToArray();

                    Assert.Equal(1, results.Length);
                    Assert.Equal(1, verifierStub.IsValidCallCount);

                    results = (await discoverer.DiscoverAsync(CancellationToken.None)).ToArray();

                    Assert.Equal(1, results.Length);
                    Assert.Equal(1, verifierStub.IsValidCallCount);
                }
            }
        }
Exemplo n.º 5
0
        public void AddRemoveMissingReferences()
        {
            DiscoverDoneEventArgs lastDiscoverEventArgs = null;

            PluginDiscoverer discoverer = new PluginDiscoverer();

            discoverer.DiscoverDone += (sender, e) => lastDiscoverEventArgs = e;

            TestBase.CopyPluginToTestDir("ServiceC.dll");

            discoverer.Discover(TestBase.TestFolderDir, true);
            Assert.That(lastDiscoverEventArgs.NewAssemblies.Count, Is.EqualTo(1));
            IAssemblyInfo pAss = lastDiscoverEventArgs.NewAssemblies[0];

            Assert.That(pAss.HasError, Is.True);
            Assert.That(lastDiscoverEventArgs.NewPlugins.Count, Is.EqualTo(0));
            Assert.That(lastDiscoverEventArgs.NewServices.Count, Is.EqualTo(0));
            Assert.That(lastDiscoverEventArgs.NewDisappearedAssemblies.Count, Is.EqualTo(0));

            TestBase.CopyPluginToTestDir("ServiceC.Model.dll");

            discoverer.Discover(TestBase.TestFolderDir, true);
            Assert.That(lastDiscoverEventArgs.NewPlugins.Count, Is.EqualTo(1));
            Assert.That(lastDiscoverEventArgs.NewServices.Count, Is.EqualTo(1));
            Assert.That(pAss.HasError, Is.False, "The assembly info reference is updated.");

            Assert.That(lastDiscoverEventArgs.ChangedAssemblies.Count, Is.EqualTo(1));
            Assert.That(lastDiscoverEventArgs.ChangedAssemblies[0], Is.SameAs(pAss));

            Assert.That(lastDiscoverEventArgs.NewDisappearedAssemblies.Count, Is.EqualTo(0));
            Assert.That(lastDiscoverEventArgs.DeletedDisappearedAssemblies.Count, Is.EqualTo(0));
        }
Exemplo n.º 6
0
        public void AddBetterPlugins()
        {
            DiscoverDoneEventArgs lastDiscoverEventArgs = null;

            PluginDiscoverer discoverer = new PluginDiscoverer();

            discoverer.DiscoverDone += (sender, e) => lastDiscoverEventArgs = e;

            TestBase.CopyPluginToTestDir("ServiceA.Old.dll");

            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(lastDiscoverEventArgs.NewPlugins.Count, Is.EqualTo(1));
            Assert.That(lastDiscoverEventArgs.NewOldPlugins.Count, Is.EqualTo(0));

            IPluginInfo bestVersion = discoverer.FindPlugin(new System.Guid("{12A9FCC0-ECDC-4049-8DBF-8961E49A9EDE}"));

            Assert.That(bestVersion.Version == new Version("1.0.0"));

            TestBase.CopyPluginToTestDir("ServiceA.dll");

            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(lastDiscoverEventArgs.NewPlugins.Count, Is.EqualTo(0));
            Assert.That(lastDiscoverEventArgs.NewOldPlugins.Count, Is.EqualTo(1));

            IPluginInfo newBestVersion = discoverer.FindPlugin(new System.Guid("{12A9FCC0-ECDC-4049-8DBF-8961E49A9EDE}"));

            Assert.That(newBestVersion.Version == new Version("1.1.0"));

            Assert.That(bestVersion.GetHashCode() == newBestVersion.GetHashCode());
        }
Exemplo n.º 7
0
        public static IReadOnlyCollection <PluginMetadata> DiscoverPlugins()
        {
            var pluginPaths   = GetPluginPaths();
            var pluginLoaders = Bootstrapper.LoadPlugins(pluginPaths);

            return(PluginDiscoverer.Discover(pluginLoaders.Assemblies));
        }
Exemplo n.º 8
0
        public void TestDiscoverOnePlugin()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();

            TestBase.CopyPluginToTestDir("ServiceA.dll");

            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(discoverer.AllAssemblies.Count == 1);
            Assert.That(discoverer.PluginOrServiceAssemblies.Count == 1);
            Assert.That(discoverer.Plugins.Count == 1);
            Assert.That(discoverer.Services.Count == 1);

            //Test methods, events and properties info :
            IReadOnlyCollection <ISimpleEventInfo>    events     = discoverer.Services.First().EventsInfoCollection;
            IReadOnlyCollection <ISimpleMethodInfo>   methods    = discoverer.Services.First().MethodsInfoCollection;
            IReadOnlyCollection <ISimplePropertyInfo> properties = discoverer.Services.First().PropertiesInfoCollection;

            Assert.That(events.Count, Is.EqualTo(1));
            Assert.That(methods.Count, Is.EqualTo(2));
            Assert.That(properties.Count, Is.EqualTo(1));

            Assert.That(events.First().Name, Is.EqualTo("HasStarted"));

            Assert.That(methods.First().Name, Is.EqualTo("Add"));
            Assert.That(methods.First().Parameters.Count, Is.EqualTo(2));
            Assert.That(methods.First().Parameters.First().ParameterName, Is.EqualTo("a"));
            Assert.That(methods.First().Parameters.Last().ParameterName, Is.EqualTo("b"));
            Assert.That(methods.First().ReturnType, Is.EqualTo("System.Int32"));

            Assert.That(properties.First().Name, Is.EqualTo("HasBeenStarted"));
            Assert.That(properties.First().PropertyType, Is.EqualTo("System.Boolean"));
        }
Exemplo n.º 9
0
        public void TestRequireConfiguration()
        {
            int passed = 0;

            PluginDiscoverer discoverer = new PluginDiscoverer();

            TestBase.CopyPluginToTestDir("ServiceA.dll");
            TestBase.CopyPluginToTestDir("ServiceB.dll");
            TestBase.CopyPluginToTestDir("EditorsOfPlugins.dll");
            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(discoverer.Plugins.Count, Is.EqualTo(6));
            foreach (IPluginInfo plugin in discoverer.Plugins)
            {
                if (plugin.PluginId == new Guid("{8BE8C487-4052-46b0-9225-708BC2A1E033}"))    //EditorOfPlugin01
                {
                    Assert.That(plugin.EditorsInfo.Count, Is.EqualTo(1));
                    Assert.That(plugin.EditorsInfo[0].ConfigurationPropertyName == "EditedPluginConfiguration");
                    Assert.IsTrue(plugin.EditorsInfo[0].IsConfigurationPropertyValid);
                    passed++;
                }
                else if (plugin.PluginId == new Guid("{EDA76E35-30C2-449e-817C-91CB24D38763}"))    //EditorOfPlugin02
                {
                    Assert.That(plugin.EditorsInfo.Count, Is.EqualTo(1));
                    Assert.IsTrue(plugin.EditorsInfo[0].IsConfigurationPropertyValid);
                    passed++;
                }
            }

            Assert.That(passed, Is.EqualTo(2));
        }
Exemplo n.º 10
0
        public async Task DiscoverAsync_IsIdempotent()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var pluginPath = Path.Combine(testDirectory.Path, "a");

                File.WriteAllText(pluginPath, string.Empty);

                var verifierSpy = new Mock <EmbeddedSignatureVerifier>();

                verifierSpy.Setup(spy => spy.IsValid(It.IsAny <string>()))
                .Returns(true);

                using (var discoverer = new PluginDiscoverer(pluginPath, verifierSpy.Object))
                {
                    var firstResult = await discoverer.DiscoverAsync(CancellationToken.None);

                    verifierSpy.Verify(spy => spy.IsValid(It.IsAny <string>()),
                                       Times.Once);

                    var secondResult = await discoverer.DiscoverAsync(CancellationToken.None);

                    verifierSpy.Verify(spy => spy.IsValid(It.IsAny <string>()),
                                       Times.Once);

                    Assert.Same(firstResult, secondResult);
                }
            }
        }
Exemplo n.º 11
0
        public void RefExternalNonDynamicService()
        {
            {
                // Missing ServiceC.Model.dll assembly: the interface has no definition.
                PluginDiscoverer discoverer = new PluginDiscoverer();
                TestBase.CopyPluginToTestDir("RefExternalNonDynamicService.dll");

                discoverer.Discover(TestBase.TestFolderDir, true);

                Assert.That(discoverer.AllAssemblies.Count, Is.EqualTo(1));
                Assert.That(discoverer.AllAssemblies.First().HasError, Is.True);

                Assert.That(discoverer.AllPlugins.Count, Is.EqualTo(0));
                Assert.That(discoverer.AllServices.Count, Is.EqualTo(0));
            }
            {
                PluginDiscoverer discoverer = new PluginDiscoverer();
                TestBase.CopyPluginToTestDir("ServiceC.Model.dll");

                discoverer.Discover(TestBase.TestFolderDir, true);

                Assert.That(discoverer.Plugins.Count, Is.EqualTo(2), "There are 2 runnable plugins.");
                Assert.That(discoverer.Plugins.Select(x => x.PublicName).OrderBy(Util.FuncIdentity).SequenceEqual(new[] { "PluginSuccess", "PluginSuccessAlso" }));

                Assert.That(discoverer.AllPlugins.Count, Is.EqualTo(3), "There are 2 runnable plugins and 1 in error.");
                Assert.That(discoverer.AllPlugins.Any(p => p.PublicName == "PluginFailed"));
            }
        }
Exemplo n.º 12
0
        public void AddRemoveAssemblies()
        {
            DiscoverDoneEventArgs lastDiscoverEventArgs = null;

            PluginDiscoverer discoverer = new PluginDiscoverer();

            discoverer.DiscoverDone += (sender, e) => lastDiscoverEventArgs = e;

            // Add 3 assemblies
            TestBase.CopyPluginToTestDir("ServiceA.dll");
            TestBase.CopyPluginToTestDir("ServiceB.dll");
            TestBase.CopyPluginToTestDir("ServiceC.dll");

            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(lastDiscoverEventArgs.NewAssemblies.Count, Is.EqualTo(3));


            // Remove all assmeblies, add the first two then add a new one.
            TestBase.CleanupTestDir();
            TestBase.CopyPluginToTestDir("ServiceA.dll");
            TestBase.CopyPluginToTestDir("ServiceB.dll");
            TestBase.CopyPluginToTestDir("EditorsOfPlugins.dll");

            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(lastDiscoverEventArgs.NewAssemblies.Count, Is.EqualTo(1));
            Assert.That(lastDiscoverEventArgs.DeletedAssemblies.Count, Is.EqualTo(1));
        }
Exemplo n.º 13
0
        //TODO <ServiceVertex, CKEdge>
        private AdjacencyGraph <IVertex, CKEdge> BuildServicesThree(String ckAssemblieFolder)
        {
            PluginDiscoverer     discoverer      = GetFooBarPluginDiscoverer(ckAssemblieFolder);
            List <ServiceVertex> serviceVertices = new List <ServiceVertex>();
            var serviceThree = new AdjacencyGraph <IVertex, CKEdge>();

            ConsoleManager.Toggle();

            foreach (IServiceInfo serv in discoverer.AllServices)
            {
                serviceVertices.Add(new ServiceVertex(serv));
            }

            foreach (ServiceVertex servVertex in serviceVertices)
            {
                if (servVertex.Service.Generalization != null)
                {
                    ServiceVertex gen = serviceVertices.Where(
                        delegate(ServiceVertex item)
                    {
                        if (item.Service == servVertex.Service.Generalization)
                        {
                            return(true);
                        }
                        return(false);
                    }
                        ).First();

                    serviceThree.AddVerticesAndEdge(
                        new CKEdge(servVertex, gen)
                        );
                }
                else
                {
                    serviceThree.AddVertex(servVertex);
                }
            }

            /* foreach(IServiceInfo serv in discoverer.AllServices)
             * {
             *   if (serv.Generalization != null)
             *   {
             *       /*serviceThree.AddVerticesAndEdge(
             *           new TaggedEdge<IServiceInfo, string>(serv, serv.Generalization, String.Format("{0} generalisation", serv.ServiceFullName))
             *       );/
             *       serviceThree.AddVerticesAndEdge(
             *              new CKEdge(new ServiceVertex(serv), new ServiceVertex(serv.Generalization))
             *           );
             *   }
             *   else
             *   {
             *       serviceThree.AddVertex(new ServiceVertex(serv));
             *   }
             * }*/

            Console.WriteLine(serviceThree);
            ConsoleManager.Toggle();
            return(serviceThree);
        }
Exemplo n.º 14
0
 public async Task DiscoverAsync_ThrowsIfCancelled()
 {
     using (var discoverer = new PluginDiscoverer(
                rawPluginPaths: "",
                verifier: Mock.Of <EmbeddedSignatureVerifier>()))
     {
         await Assert.ThrowsAsync <OperationCanceledException>(
             () => discoverer.DiscoverAsync(new CancellationToken(canceled: true)));
     }
 }
Exemplo n.º 15
0
        public void HomonymServices()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();

            TestBase.CopyPluginToTestDir("HomonymServiceZ.dll");
            TestBase.CopyPluginToTestDir("HomonymServiceZbis.dll");
            TestBase.CopyPluginToTestDir("HomonymClassZ.dll");
            TestBase.CopyPluginToTestDir("HomonymClassZbis.dll");

            List <object> objects = new List <object>();

            foreach (FileInfo f in TestBase.TestFolderDir.GetFiles("*.dll"))
            {
                objects.Add(Load(f.FullName));
            }

            //object[0] is a HomonymClassZ object
            //object[1] is a HomonymClassZbis object

            //object[2] is a HomonymImplZ object
            //object[3] is a HomonymImplZbis object

            object objectZ    = objects[0];
            object objectZbis = objects[1];
            object implZ      = objects[2];
            object implZbis   = objects[3];

            //Assert that a "Zbis" impl can't be set in the "Z" object's property
            Assert.Throws <System.Reflection.TargetException>(() => objectZ.GetType().GetProperty("Service").SetValue(objectZbis, implZ, null));
            //Assert that a "Z" impl can't be set in the "Zbis" object's property
            Assert.Throws <System.Reflection.TargetException>(() => objectZbis.GetType().GetProperty("Service").SetValue(objectZ, implZ, null));

            objectZ.GetType().GetProperty("Service").SetValue(objectZ, implZ, null);
            objectZbis.GetType().GetProperty("Service").SetValue(objectZbis, implZbis, null);

            object propertyZ    = objectZ.GetType().GetProperty("Service").GetValue(objectZ, null);
            object propertyZbis = objectZbis.GetType().GetProperty("Service").GetValue(objectZbis, null);

            MethodInfo m = propertyZ.GetType().GetMethod("GetNumber");

            object[] argsZ = new object[2] {
                0, 0
            };

            Assert.That(m.Invoke(propertyZ, argsZ), Is.EqualTo(2));

            MethodInfo mbis = propertyZbis.GetType().GetMethod("GetNumber");

            object[] argsZbis = new object[2] {
                0, 0
            };

            Assert.That(mbis.Invoke(propertyZbis, argsZbis), Is.EqualTo(1));
        }
        public void DownloadAsset()
        {
            var repos         = PluginDiscoverer.GetGithubPlugins();
            var testRepo      = repos.Find(x => x.Id == 133084976);
            var latestRelease = PluginDiscoverer.GetLatestRelease(testRepo);
            var firstAsset    = latestRelease.Assets[0];

            var path = PluginDiscoverer.DownloadAsset(firstAsset, Directory.GetCurrentDirectory() + @"\temp");

            Assert.AreEqual(Directory.GetCurrentDirectory() + @"\temp\Binaries.zip", path);
        }
Exemplo n.º 17
0
        public async Task DiscoverAsync_DoesNotThrowIfNoValidFilePathsAndFallbackEmbeddedSignatureVerifier()
        {
            using (var discoverer = new PluginDiscoverer(
                       rawPluginPaths: "",
                       verifier: new FallbackEmbeddedSignatureVerifier()))
            {
                var pluginFiles = await discoverer.DiscoverAsync(CancellationToken.None);

                Assert.Empty(pluginFiles);
            }
        }
Exemplo n.º 18
0
        public void DiscoverMultiServicesPlugin()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();

            TestBase.CopyPluginToTestDir("ServiceD.dll");

            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(discoverer.AllPlugins.Count == 1);
            Assert.That(discoverer.AllPlugins.ElementAt(0).HasError);
        }
        public void GetLatestRelease()
        {
            var repos         = PluginDiscoverer.GetGithubPlugins();
            var testRepo      = repos.Find(x => x.Id == 133084976);
            var latestRelease = PluginDiscoverer.GetLatestRelease(testRepo);

            Assert.AreNotEqual(null, latestRelease);
            Assert.AreNotEqual(0, latestRelease.Assets.Count);

            var firstAsset = latestRelease.Assets[0];

            Assert.AreEqual("Binaries.zip", firstAsset.Name);
        }
Exemplo n.º 20
0
        public PluginDiscoverer GetFooBarPluginDiscoverer(String ckAssemblieFolder)
        {
            PluginDiscoverer discoverer   = new PluginDiscoverer();
            bool             discoverDone = false;

            discoverer.DiscoverDone += (object sender, DiscoverDoneEventArgs e) => discoverDone = true;

            ckAssemblieFolder = ckAssemblieFolder.Replace('|', System.IO.Path.DirectorySeparatorChar);
            discoverer.Discover(new DirectoryInfo(ckAssemblieFolder), true);

            Contract.Assert(discoverDone);
            return(discoverer);
        }
Exemplo n.º 21
0
        public void RefInternalNonDynamicService()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();

            TestBase.CopyPluginToTestDir("RefInternalNonDynamicService.dll");

            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(discoverer.Plugins.Count, Is.EqualTo(2), "There are 2 runnable plugins.");
            Assert.That(discoverer.Plugins.Select(x => x.PublicName).OrderBy(Util.FuncIdentity).SequenceEqual(new[] { "PluginSuccess", "PluginSuccessAlso" }));

            Assert.That(discoverer.AllPlugins.Count, Is.EqualTo(3), "There are 2 runnable plugins and 1 in error.");
            Assert.That(discoverer.AllPlugins.Any(p => p.PublicName == "PluginFailed"));
        }
Exemplo n.º 22
0
        public void Build(BuildContext context)
        {
            DirectoryCopy(Path.GetDirectoryName(context.PathToFunctionAssembly), context.PathToTargetFolder, true, true);
            DirectoryCopy(Path.GetDirectoryName(context.PathToFunctionEntryAssembly), context.PathToTargetFolder, true, false);

            var pathToFunctionAssembly      = Path.Combine(context.PathToTargetFolder, Path.GetFileName(context.PathToFunctionAssembly));
            var pathToFunctionEntryAssembly = Path.Combine(context.PathToTargetFolder, Path.GetFileName(context.PathToFunctionEntryAssembly));

            var pluginLoaders = Bootstrapper.LoadPlugins(new[] { pathToFunctionAssembly });
            var plugins       = PluginDiscoverer.Discover(pluginLoaders.Assemblies);

            FunctionDependencyMerger.Merge(pathToFunctionEntryAssembly, pathToFunctionAssembly);
            FunctionImplementor.Implement(pathToFunctionEntryAssembly, plugins);
        }
        public void TestConsumers()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();

            TestBase.CopyPluginToTestDir("ServiceProducer.Model.dll");
            TestBase.CopyPluginToTestDir("ServiceProducer.dll");
            TestBase.CopyPluginToTestDir("ServiceConsumer.dll");
            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.That(discoverer.AllAssemblies.Count, Is.EqualTo(3));
            Assert.That(discoverer.AllPlugins.Count, Is.EqualTo(3));

            IPluginInfo c0 = discoverer.FindPlugin(new Guid("{2294F5BD-C511-456F-8E6B-A39A84FBAE51}"));
        }
Exemplo n.º 24
0
        public async Task DiscoverAsync_HandlesAllPluginFileStates()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var pluginPaths = new[] { "a", "b", "c", "d" }
                .Select(fileName => Path.Combine(testDirectory.Path, fileName))
                .ToArray();

                File.WriteAllText(pluginPaths[1], string.Empty);
                File.WriteAllText(pluginPaths[2], string.Empty);

                var responses = new Dictionary <string, bool>()
                {
                    { pluginPaths[0], false },
                    { pluginPaths[1], false },
                    { pluginPaths[2], true },
                    { pluginPaths[3], false },
                    { "e", true }
                };
                var verifierStub   = new EmbeddedSignatureVerifierStub(responses);
                var rawPluginPaths = string.Join(";", responses.Keys);

                using (var discoverer = new PluginDiscoverer(rawPluginPaths, verifierStub))
                {
                    var results = (await discoverer.DiscoverAsync(CancellationToken.None)).ToArray();

                    Assert.Equal(5, results.Length);

                    Assert.Equal(pluginPaths[0], results[0].PluginFile.Path);
                    Assert.Equal(PluginFileState.NotFound, results[0].PluginFile.State);
                    Assert.Equal($"A plugin was not found at path '{pluginPaths[0]}'.", results[0].Message);

                    Assert.Equal(pluginPaths[1], results[1].PluginFile.Path);
                    Assert.Equal(PluginFileState.InvalidEmbeddedSignature, results[1].PluginFile.State);
                    Assert.Equal($"The plugin at '{pluginPaths[1]}' did not have a valid embedded signature.", results[1].Message);

                    Assert.Equal(pluginPaths[2], results[2].PluginFile.Path);
                    Assert.Equal(PluginFileState.Valid, results[2].PluginFile.State);
                    Assert.Null(results[2].Message);

                    Assert.Equal(pluginPaths[3], results[3].PluginFile.Path);
                    Assert.Equal(PluginFileState.NotFound, results[3].PluginFile.State);
                    Assert.Equal($"A plugin was not found at path '{pluginPaths[3]}'.", results[3].Message);

                    Assert.Equal("e", results[4].PluginFile.Path);
                    Assert.Equal(PluginFileState.InvalidFilePath, results[4].PluginFile.State);
                    Assert.Equal($"The plugin file path 'e' is invalid.", results[4].Message);
                }
            }
        }
Exemplo n.º 25
0
        public async Task DiscoverAsync_ThrowsPlatformNotSupportedIfEmbeddedSignatureVerifierIsRequired()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var pluginPath = Path.Combine(testDirectory.Path, "a");

                File.WriteAllText(pluginPath, string.Empty);

                using (var discoverer = new PluginDiscoverer(pluginPath, new FallbackEmbeddedSignatureVerifier()))
                {
                    await Assert.ThrowsAsync <PlatformNotSupportedException>(
                        () => discoverer.DiscoverAsync(CancellationToken.None));
                }
            }
        }
        public void TestConsumers()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();

            TestBase.CopyPluginToTestDir( "ServiceProducer.Model.dll" );
            TestBase.CopyPluginToTestDir( "ServiceProducer.dll" );
            TestBase.CopyPluginToTestDir( "ServiceConsumer.dll" );
            discoverer.Discover( TestBase.TestFolderDir, true );

            Assert.That( discoverer.AllAssemblies.Count, Is.EqualTo( 3 ) );
            Assert.That( discoverer.AllPlugins.Count, Is.EqualTo( 3 ) );

            IPluginInfo c0 = discoverer.FindPlugin( new Guid("{2294F5BD-C511-456F-8E6B-A39A84FBAE51}") );

        }
        private void AddServices(YamlMappingNode functions, YamlMappingNode resources)
        {
            var services      = ServiceDiscoverer.Discover(_serviceDiscoveryOptions);
            var pluginLoaders = Bootstrapper.LoadPlugins(services.Select(x => x.AssemblyPath));

            foreach (var service in services)
            {
                var assembly = pluginLoaders.Assemblies.Single(x => x.GetName().Name == service.Name);
                var plugins  = PluginDiscoverer.Discover(assembly);

                foreach (var plugin in plugins)
                {
                    AddService(functions, resources, service, plugin);
                }
            }
        }
Exemplo n.º 28
0
        public async Task DiscoverAsync_DisallowsNonRootedFilePaths(string pluginPath)
        {
            var responses = new Dictionary <string, bool>()
            {
                { pluginPath, true }
            };
            var verifierStub = new EmbeddedSignatureVerifierStub(responses);

            using (var discoverer = new PluginDiscoverer(pluginPath, verifierStub))
            {
                var results = (await discoverer.DiscoverAsync(CancellationToken.None)).ToArray();

                Assert.Equal(1, results.Length);
                Assert.Equal(pluginPath, results[0].PluginFile.Path);
                Assert.Equal(PluginFileState.InvalidFilePath, results[0].PluginFile.State);
            }
        }
Exemplo n.º 29
0
		public void TestDiscoverNothing()
		{
            PluginDiscoverer discoverer = new PluginDiscoverer();

            bool discoverBegin = false;
            bool discoverDone = false;

            discoverer.DiscoverBegin += ( object sender, EventArgs e ) => discoverBegin = true;
            discoverer.DiscoverDone += ( object sender, DiscoverDoneEventArgs e ) => discoverDone = true;

            discoverer.Discover( TestBase.TestFolderDir, true );

            Assert.IsTrue( discoverDone && discoverBegin );

            Assert.That( discoverer.AllAssemblies.Count == 0 );
            Assert.That( discoverer.PluginOrServiceAssemblies.Count == 0 );
		}
Exemplo n.º 30
0
        public void TestDiscoverNothing()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();

            bool discoverBegin = false;
            bool discoverDone  = false;

            discoverer.DiscoverBegin += (object sender, EventArgs e) => discoverBegin = true;
            discoverer.DiscoverDone  += (object sender, DiscoverDoneEventArgs e) => discoverDone = true;

            discoverer.Discover(TestBase.TestFolderDir, true);

            Assert.IsTrue(discoverDone && discoverBegin);

            Assert.That(discoverer.AllAssemblies.Count == 0);
            Assert.That(discoverer.PluginOrServiceAssemblies.Count == 0);
        }
Exemplo n.º 31
0
        public RouterConfig Build()
        {
            var services      = ServiceDiscoverer.Discover(_serviceDiscoveryOptions);
            var pluginLoaders = Bootstrapper.LoadPlugins(services.Select(x => x.AssemblyPath));

            var routes = new List <RouterEntry>();

            foreach (var assembly in pluginLoaders.Assemblies)
            {
                var assemblyRoutes = PluginDiscoverer.Discover(assembly)
                                     .SelectMany(plugin => RouteDiscoverer.Discover(plugin).Select(route => ToRouterEntry(plugin, route)));

                routes.AddRange(assemblyRoutes);
            }

            return(new RouterConfig(routes));
        }
Exemplo n.º 32
0
        public PluginRunner(IServiceProvider externalServiceProvider, IConfigManager cfg)
        {
            _externalServiceProvider = externalServiceProvider;
            _config          = cfg;
            _configAccessors = new Dictionary <INamedVersionedUniqueId, PluginConfigAccessor>();
            _config.Extended.Container.Changed += OnConfigContainerChanged;
            _discoverer    = new PluginDiscoverer();
            _runningConfig = new RunningConfiguration(this);
            _requirements  = new RunnerRequirements(this);

            _host = new PluginHost();
            // 0 - For creation.
            _host.PluginCreator = CreatePlugin;
            // 1 - Before Setup call: plugin is configured.
            _host.PluginConfigurator = ConfigurePlugin;
            // 2 - Before Start: plugin is aware of its environment.
            _host.ServiceReferencesBinder = ConfigureServiceReferences;
        }
Exemplo n.º 33
0
        public void AddRemoveEditors()
        {
            DiscoverDoneEventArgs lastDiscoverEventArgs = null;

            PluginDiscoverer discoverer = new PluginDiscoverer();

            discoverer.DiscoverDone += (sender, e) => lastDiscoverEventArgs = e;

            TestBase.CopyPluginToTestDir("ServiceA.dll");
            TestBase.CopyPluginToTestDir("ServiceB.dll");
            TestBase.CopyPluginToTestDir("EditorsOfPlugins.dll");
            discoverer.Discover(TestBase.TestFolderDir, true);
            Assert.That(lastDiscoverEventArgs.NewEditors.Count, Is.EqualTo(6));

            TestBase.CleanupTestDir();
            discoverer.Discover(TestBase.TestFolderDir, true);
            Assert.That(lastDiscoverEventArgs.NewEditors.Count, Is.EqualTo(0));
            Assert.That(lastDiscoverEventArgs.DeletedEditors.Count, Is.EqualTo(6));
        }
Exemplo n.º 34
0
        public PluginDiscoverer GetFooBarPluginDiscoverer(String ckAssemblieFolder)
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();
            bool discoverDone = false;

            discoverer.DiscoverDone += (object sender, DiscoverDoneEventArgs e) => discoverDone = true;

            ckAssemblieFolder = ckAssemblieFolder.Replace('|', System.IO.Path.DirectorySeparatorChar);
            discoverer.Discover(new DirectoryInfo(ckAssemblieFolder), true);

            Contract.Assert(discoverDone);
            return discoverer;
        }
Exemplo n.º 35
0
        public void RefExternalNonDynamicService()
        {
            {
                // Missing ServiceC.Model.dll assembly: the interface has no definition.
                PluginDiscoverer discoverer = new PluginDiscoverer();
                TestBase.CopyPluginToTestDir( "RefExternalNonDynamicService.dll" );

                discoverer.Discover( TestBase.TestFolderDir, true );

                Assert.That( discoverer.AllAssemblies.Count, Is.EqualTo( 1 ) );
                Assert.That( discoverer.AllAssemblies.First().HasError, Is.True );

                Assert.That( discoverer.AllPlugins.Count, Is.EqualTo( 0 ) );
                Assert.That( discoverer.AllServices.Count, Is.EqualTo( 0 ) );
            }
            {
                PluginDiscoverer discoverer = new PluginDiscoverer();
                TestBase.CopyPluginToTestDir( "ServiceC.Model.dll" );

                discoverer.Discover( TestBase.TestFolderDir, true );

                Assert.That( discoverer.Plugins.Count, Is.EqualTo( 2 ), "There are 2 runnable plugins." );
                Assert.That( discoverer.Plugins.Select( x => x.PublicName ).OrderBy( Util.FuncIdentity ).SequenceEqual( new[] { "PluginSuccess", "PluginSuccessAlso" } ) );

                Assert.That( discoverer.AllPlugins.Count, Is.EqualTo( 3 ), "There are 2 runnable plugins and 1 in error." );
                Assert.That( discoverer.AllPlugins.Any( p => p.PublicName == "PluginFailed" ) );
            }

        }
Exemplo n.º 36
0
        public void RefInternalNonDynamicService()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();

            TestBase.CopyPluginToTestDir( "RefInternalNonDynamicService.dll" );

            discoverer.Discover( TestBase.TestFolderDir, true );

            Assert.That( discoverer.Plugins.Count, Is.EqualTo( 2 ), "There are 2 runnable plugins." );
            Assert.That( discoverer.Plugins.Select( x => x.PublicName ).OrderBy( Util.FuncIdentity ).SequenceEqual( new[] { "PluginSuccess", "PluginSuccessAlso" } ) );

            Assert.That( discoverer.AllPlugins.Count, Is.EqualTo( 3 ), "There are 2 runnable plugins and 1 in error." );
            Assert.That( discoverer.AllPlugins.Any( p => p.PublicName == "PluginFailed" ) );
        }
Exemplo n.º 37
0
        public void HomonymServices()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();

            TestBase.CopyPluginToTestDir( "HomonymServiceZ.dll" );
            TestBase.CopyPluginToTestDir( "HomonymServiceZbis.dll" );
            TestBase.CopyPluginToTestDir( "HomonymClassZ.dll" );
            TestBase.CopyPluginToTestDir( "HomonymClassZbis.dll" );

            List<object> objects = new List<object>();

            foreach ( FileInfo f in TestBase.TestFolderDir.GetFiles( "*.dll" ) )
            {
                objects.Add( Load( f.FullName ) );
            }

            //object[0] is a HomonymClassZ object
            //object[1] is a HomonymClassZbis object            

            //object[2] is a HomonymImplZ object
            //object[3] is a HomonymImplZbis object

            object objectZ = objects[0];
            object objectZbis = objects[1];
            object implZ = objects[2];
            object implZbis = objects[3];

            //Assert that a "Zbis" impl can't be set in the "Z" object's property
            Assert.Throws<System.Reflection.TargetException>( () => objectZ.GetType().GetProperty( "Service" ).SetValue( objectZbis, implZ, null ) );
            //Assert that a "Z" impl can't be set in the "Zbis" object's property
            Assert.Throws<System.Reflection.TargetException>( () => objectZbis.GetType().GetProperty( "Service" ).SetValue( objectZ, implZ, null ) );

            objectZ.GetType().GetProperty( "Service" ).SetValue( objectZ, implZ, null );
            objectZbis.GetType().GetProperty( "Service" ).SetValue( objectZbis, implZbis, null );

            object propertyZ = objectZ.GetType().GetProperty( "Service" ).GetValue( objectZ, null );
            object propertyZbis = objectZbis.GetType().GetProperty( "Service" ).GetValue( objectZbis, null );

            MethodInfo m = propertyZ.GetType().GetMethod( "GetNumber" );
            object[] argsZ = new object[2] { 0, 0 };
           
            Assert.That( m.Invoke( propertyZ, argsZ), Is.EqualTo( 2 ) );

            MethodInfo mbis = propertyZbis.GetType().GetMethod( "GetNumber" );
            object[] argsZbis = new object[2] { 0, 0 };

            Assert.That( mbis.Invoke( propertyZbis, argsZbis ), Is.EqualTo( 1 ) );
        }
Exemplo n.º 38
0
        public void DiscoverMultiServicesPlugin()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();            

            TestBase.CopyPluginToTestDir( "ServiceD.dll" );

            discoverer.Discover( TestBase.TestFolderDir, true );

            Assert.That( discoverer.AllPlugins.Count == 1 );
            Assert.That( discoverer.AllPlugins.ElementAt( 0 ).HasError );
        }
Exemplo n.º 39
0
        public void TestRequireConfiguration()
        {
            int passed = 0;

            PluginDiscoverer discoverer = new PluginDiscoverer();
            
            TestBase.CopyPluginToTestDir( "ServiceA.dll" );
            TestBase.CopyPluginToTestDir( "ServiceB.dll" );
            TestBase.CopyPluginToTestDir( "EditorsOfPlugins.dll" );
            discoverer.Discover( TestBase.TestFolderDir, true );

            Assert.That( discoverer.Plugins.Count, Is.EqualTo( 6 ) );
            foreach( IPluginInfo plugin in discoverer.Plugins )
            {
                if( plugin.PluginId == new Guid( "{8BE8C487-4052-46b0-9225-708BC2A1E033}" ) ) //EditorOfPlugin01
                {
                    Assert.That( plugin.EditorsInfo.Count, Is.EqualTo( 1 ) );
                    Assert.That( plugin.EditorsInfo[0].ConfigurationPropertyName == "EditedPluginConfiguration" );
                    Assert.IsTrue( plugin.EditorsInfo[0].IsConfigurationPropertyValid );
                    passed++;
                }
                else if( plugin.PluginId == new Guid( "{EDA76E35-30C2-449e-817C-91CB24D38763}" ) ) //EditorOfPlugin02
                {
                    Assert.That( plugin.EditorsInfo.Count, Is.EqualTo( 1 ) );
                    Assert.IsTrue( plugin.EditorsInfo[0].IsConfigurationPropertyValid );
                    passed++;
                }
            }

            Assert.That( passed, Is.EqualTo( 2 ) );
        }
Exemplo n.º 40
0
        public void TestDiscoverOldVersionnedPlugins()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();
            
            TestBase.CopyPluginToTestDir( "VersionedPlugins.dll" );
            TestBase.CopyPluginToTestDir( "VersionedPluginWithService.dll" );

            discoverer.Discover( TestBase.TestFolderDir, true );

            Assert.That( discoverer.AllAssemblies.Count, Is.EqualTo( 2 ) );
            Assert.That( discoverer.AllPlugins.Count, Is.EqualTo( 4 ) );
            Assert.That( discoverer.AllServices.Count, Is.EqualTo( 1 ) );
            Assert.That( discoverer.Services.Count, Is.EqualTo( 1 ) );
            Assert.That( discoverer.OldVersionnedPlugins.Count, Is.EqualTo( 2 ) );
            Assert.That( discoverer.Plugins.Count == 2 );

            Assert.That( discoverer.Services.ElementAt( 0 ).Implementations.Count, Is.EqualTo( 1 ) ); // the best version of the implementation
            Assert.That( !discoverer.Services.ElementAt( 0 ).Implementations.Any( ( p ) => discoverer.OldVersionnedPlugins.Contains( p ) ) );
        }
Exemplo n.º 41
0
        public void TestCollectionEditableBy()
        {
            int passed = 0;
            PluginDiscoverer discoverer = new PluginDiscoverer();
            
            TestBase.CopyPluginToTestDir( "ServiceA.dll" );
            TestBase.CopyPluginToTestDir( "ServiceB.dll" );
            TestBase.CopyPluginToTestDir( "EditorsOfPlugins.dll" );
            discoverer.Discover( TestBase.TestFolderDir, true );

            Assert.That( discoverer.Plugins.Count, Is.EqualTo( 6 ) );
            foreach( IPluginInfo plugin in discoverer.Plugins )
            {
                if( plugin.PluginId == new Guid( "{12A9FCC0-ECDC-4049-8DBF-8961E49A9EDE}" ) ) //Plugin01
                {
                    Assert.That( plugin.EditableBy.Count, Is.EqualTo( 3 ) );
                    // Edited by EditorOfPlugin01
                    Assert.That( plugin.EditableBy.Any(
                        ( editor ) => { return editor.Plugin.PluginId == new Guid( "{8BE8C487-4052-46b0-9225-708BC2A1E033}" ); } ) );
                    // Edited by EditorOfPlugin01And02
                    Assert.That( plugin.EditableBy.Any(
                        ( editor ) => { return editor.Plugin.PluginId == new Guid( "{BC7E641B-E4EE-47f5-833B-0AFFFAA2A683}" ); } ) );
                    // Edited by itself
                    Assert.That( plugin.EditableBy.Any(
                        ( editor ) => { return editor.Plugin.PluginId == new Guid( "{12A9FCC0-ECDC-4049-8DBF-8961E49A9EDE}" ); } ) );
                    
                    passed++;
                }
                else if( plugin.PluginId == new Guid( "{E64F17D5-DCAB-4a07-8CEE-901A87D8295E}" ) ) //Plugin02
                {
                    Assert.That( plugin.EditableBy.Count, Is.EqualTo( 2 ) );
                    // Edited by EditorOfPlugin02
                    Assert.That( plugin.EditableBy.Any(
                        ( editor ) => { return editor.Plugin.PluginId == new Guid( "{EDA76E35-30C2-449e-817C-91CB24D38763}" ); } ) );
                    // Edited by EditorOfPlugin01And02
                    Assert.That( plugin.EditableBy.Any(
                        ( editor ) => { return editor.Plugin.PluginId == new Guid( "{BC7E641B-E4EE-47f5-833B-0AFFFAA2A683}" ); } ) );
                    passed++;
                }
            }
            Assert.That( passed, Is.EqualTo( 2 ) );
        }
Exemplo n.º 42
0
        public void TestDiscoverEditors()
        {
            int nbEditors = 0;

            PluginDiscoverer discoverer = new PluginDiscoverer();
            
            TestBase.CopyPluginToTestDir( "ServiceA.dll" );
            TestBase.CopyPluginToTestDir( "ServiceB.dll" );
            TestBase.CopyPluginToTestDir( "EditorsOfPlugins.dll" );
            discoverer.Discover( TestBase.TestFolderDir, true );

            Assert.That( discoverer.AllAssemblies.Count == 3 );
            Assert.That( discoverer.PluginOrServiceAssemblies.Count == 3 );
            Assert.That( discoverer.Plugins.Count, Is.EqualTo( 6 ) );

            foreach( IPluginInfo plugin in discoverer.Plugins )
            {
                nbEditors += plugin.EditorsInfo.Count;
            }

            Assert.That( nbEditors, Is.EqualTo( 6 ) ); // 6 because ServiceA get an accessor to its configuration.

            IPluginInfo editorOfTwoPlugins = discoverer.FindPlugin( new Guid( "{BC7E641B-E4EE-47f5-833B-0AFFFAA2A683}" ) );
            Assert.That( editorOfTwoPlugins.EditorsInfo.Any( ( a ) => { return (a.ConfigurationPropertyName == "ConfigPlugin01") && (a.IsConfigurationPropertyValid); } ) );
            Assert.That( editorOfTwoPlugins.EditorsInfo.Any( ( a ) => { return (a.ConfigurationPropertyName == "ConfigPlugin02") && (a.IsConfigurationPropertyValid); } ) );
        }
Exemplo n.º 43
0
        public void TestDiscoverTwoPlugins()
        {
            PluginDiscoverer discoverer = new PluginDiscoverer();
            
            TestBase.CopyPluginToTestDir( "ServiceA.dll" );
            TestBase.CopyPluginToTestDir( "ServiceB.dll" );
            discoverer.Discover( TestBase.TestFolderDir, true );

            Assert.That( discoverer.AllAssemblies.Count == 2 );
            Assert.That( discoverer.PluginOrServiceAssemblies.Count == 2 );
            Assert.That( discoverer.Plugins.Count == 2 );
            Assert.That( discoverer.Services.Count == 2 );

            foreach( IServiceInfo s in discoverer.Services )
            {
                if( s.IsDynamicService )
                {
                    Assert.That( s.AssemblyInfo != null );
                    Assert.That( s.AssemblyQualifiedName != "" );
                }
            }

            //Test methods, events and properties info of service A
            IReadOnlyCollection<ISimpleEventInfo> eventsA = discoverer.Services.First().EventsInfoCollection;
            IReadOnlyCollection<ISimpleMethodInfo> methodsA = discoverer.Services.First().MethodsInfoCollection;
            IReadOnlyCollection<ISimplePropertyInfo> propertiesA = discoverer.Services.First().PropertiesInfoCollection;

            Assert.That( eventsA.Count, Is.EqualTo( 1 ) );
            Assert.That( methodsA.Count, Is.EqualTo( 2 ) );
            Assert.That( propertiesA.Count, Is.EqualTo( 1 ) );

            Assert.That( eventsA.First().Name, Is.EqualTo( "HasStarted" ) );

            Assert.That( methodsA.First().Name, Is.EqualTo( "Add" ) );
            Assert.That( methodsA.First().Parameters.Count, Is.EqualTo( 2 ) );
            Assert.That( methodsA.First().Parameters.First().ParameterName, Is.EqualTo( "a" ) );
            Assert.That( methodsA.First().Parameters.Last().ParameterName, Is.EqualTo( "b" ) );
            Assert.That( methodsA.First().ReturnType, Is.EqualTo( "System.Int32" ) );

            Assert.That( propertiesA.First().Name, Is.EqualTo( "HasBeenStarted" ) );
            Assert.That( propertiesA.First().PropertyType, Is.EqualTo( "System.Boolean" ) );


            //Test methods, events and properties info of service B
            IReadOnlyCollection<ISimpleEventInfo> eventsB = discoverer.Services.ElementAt( 1 ).EventsInfoCollection;
            IReadOnlyCollection<ISimpleMethodInfo> methodsB = discoverer.Services.ElementAt( 1 ).MethodsInfoCollection;
            IReadOnlyCollection<ISimplePropertyInfo> propertiesB = discoverer.Services.ElementAt( 1 ).PropertiesInfoCollection;

            Assert.That( eventsB.Count, Is.EqualTo( 0 ) );
            Assert.That( methodsB.Count, Is.EqualTo( 2 ) );
            Assert.That( propertiesA.Count, Is.EqualTo( 1 ) );

            Assert.That( methodsB.First().Name, Is.EqualTo( "Mult" ) );
            Assert.That( methodsB.First().Parameters.Count, Is.EqualTo( 2 ) );
            Assert.That( methodsB.First().Parameters.First().ParameterName, Is.EqualTo( "a" ) );
            Assert.That( methodsB.First().Parameters.Last().ParameterName, Is.EqualTo( "b" ) );
            Assert.That( methodsB.First().ReturnType, Is.EqualTo( "System.Int32" ) );

            Assert.That( methodsB.ElementAt( 1 ).Name, Is.EqualTo( "Substract" ) );
            Assert.That( methodsB.ElementAt( 1 ).Parameters.Count, Is.EqualTo( 3 ) );
            Assert.That( methodsB.ElementAt( 1 ).Parameters.First().ParameterName, Is.EqualTo( "a" ) );
            Assert.That( methodsB.ElementAt( 1 ).Parameters.ElementAt( 1 ).ParameterName, Is.EqualTo( "b" ) );
            Assert.That( methodsB.ElementAt( 1 ).Parameters.Last().ParameterName, Is.EqualTo( "isAboveZero" ) );
            Assert.That( methodsB.ElementAt( 1 ).ReturnType, Is.EqualTo( "System.Int32" ) );

            Assert.That( propertiesB.First().Name, Is.EqualTo( "HasBeenStarted" ) );
            Assert.That( propertiesB.First().PropertyType, Is.EqualTo( "System.Boolean" ) );
        }