Exemplo n.º 1
0
        public void Import_from_adds_all_new_PluginFamily_from_source()
        {
            var sourceFamily  = new PluginFamily(typeof(ISomething <>));
            var sourceFamily2 = new PluginFamily(typeof(ISomething2 <>));
            var sourceFamily3 = new PluginFamily(typeof(ISomething3 <>));
            var source        = new GenericsPluginGraph();

            source.AddFamily(sourceFamily);
            source.AddFamily(sourceFamily2);
            source.AddFamily(sourceFamily3);

            var destination = new GenericsPluginGraph();

            destination.ImportFrom(source);

            Assert.AreEqual(3, destination.FamilyCount);

            Assert.AreNotSame(sourceFamily, destination.FindFamily(typeof(ISomething <>)));
        }
Exemplo n.º 2
0
        public void GetTemplatedFamily()
        {
            var          pluginGraph = new PluginGraph();
            PluginFamily family      = pluginGraph.FindFamily(typeof(IGenericService <>));

            family.AddPlugin(typeof(GenericService <>), "Default");
            family.AddPlugin(typeof(SecondGenericService <>), "Second");
            family.AddPlugin(typeof(ThirdGenericService <>), "Third");

            var genericsGraph = new GenericsPluginGraph();

            genericsGraph.AddFamily(family);

            PluginFamily templatedFamily = genericsGraph.CreateTemplatedFamily(typeof(IGenericService <int>),
                                                                               new ProfileManager());

            Assert.IsNotNull(templatedFamily);
            Assert.AreEqual(typeof(IGenericService <int>), templatedFamily.PluginType);
        }