Exemple #1
0
        public void LoadTwoSamePlugins()
        {
            var col   = new PluginsCollection();
            var plug1 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);
            var plug2 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.NotNull(plug1);
            Assert.NotNull(plug2);
            Assert.NotEqual(plug1.GetHashCode(), plug2.GetHashCode());
            Assert.NotEqual(plug1.GetHashCode(), plug2.GetHashCode());
            Assert.Equal(col.Count(), 2);
        }
Exemple #2
0
        public void LoadTestPluginByAssemblyAndName()
        {
            var col  = new PluginsCollection();
            var plug = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.Equal(col.Count(), 1);
            Assert.NotNull(plug);
        }
        public void LoadTestPluginByAssemblyAndName()
        {
            var col = new PluginsCollection();
            var plug = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.Equal(col.Count(), 1);
            Assert.NotNull(plug);
        }
        public void LoadTestPluginByAssemblyWithoutExtension()
        {
            var col = new PluginsCollection();
            var plug = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY_WITHOUT_EXTENSION);

            Assert.Equal(plug.Count(), 1);
            Assert.Equal(col.Count(), 1);
        }
Exemple #5
0
        public void LoadTestPluginByAssemblyWithoutExtension()
        {
            var col  = new PluginsCollection();
            var plug = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY_WITHOUT_EXTENSION);

            Assert.Equal(plug.Count(), 1);
            Assert.Equal(col.Count(), 1);
        }
Exemple #6
0
        public void LoadTestPluginByAssembly()
        {
            var col   = new PluginsCollection();
            var plug  = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY);
            var count = plug.Count();

            Assert.Equal(count, 1);
            Assert.Equal(col.Count(), 1);
        }
        public void LoadTestPluginByAssembly()
        {
            var col = new PluginsCollection();
            var plug = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY);
            var count = plug.Count();

            Assert.Equal(count, 1);
            Assert.Equal(col.Count(), 1);
        }
Exemple #8
0
        public void LoadAndCheckContainsPlugin()
        {
            var col = new PluginsCollection();

            col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.True(col.Contains(TEST_PLUGIN1_FULLNAME));
            Assert.False(col.Contains("fsefsefse"));
        }
Exemple #9
0
        public void LoadAndSelectPlugin()
        {
            var col   = new PluginsCollection();
            var plug1 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);
            var plug2 = col[TEST_PLUGIN1_FULLNAME].FirstOrDefault();

            Assert.Equal(plug1, plug2);
            Assert.Equal(plug1, plug2);
        }
Exemple #10
0
        public void LoadAndUsingPluginsWithGCCollect()
        {
            var col   = new PluginsCollection();
            var plug1 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);
            var plug2 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.NotNull(plug1);
            Assert.NotNull(plug2);
            Assert.Equal(col.Count(), 2);

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            Assert.DoesNotThrow(() => plug1.GetFields());
            Assert.DoesNotThrow(plug1.Close);
            Assert.DoesNotThrow(() => plug2.GetFields());
            Assert.DoesNotThrow(plug2.Close);
        }
Exemple #11
0
        public void LoadAndRemoveAllPlugins()
        {
            var col  = new PluginsCollection();
            var plug = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.NotNull(plug);
            Assert.True(col.Any());

            col.StopAndRemoveAll();
            Assert.Equal(col.Count(), 0);
        }
        public void LoadAndRemoveAllPlugins()
        {
            var col = new PluginsCollection();
            var plug = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.NotNull(plug);
            Assert.True(col.Any());

            col.StopAndRemoveAll();
            Assert.Equal(col.Count(), 0);
        }
        private void loadAllPlugins()
        {
            checkIfPluginsDirExists();
            var assemblies = getAssembliesToLoad();

            foreach (var assembly in assemblies)
            {
                _pluginsCollection.LoadPlugin(assembly);
            }
            informAboutChange();
        }
Exemple #14
0
        public void LoadAndRemoveAllPluginsAndGCCollect()
        {
            var col   = new PluginsCollection();
            var plug1 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);
            var plug2 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.NotNull(plug1);
            Assert.NotNull(plug2);
            Assert.Equal(col.Count(), 2);

            col.StopAndRemoveAll();
            Assert.Equal(col.Count(), 0);

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            Assert.Throws <AppDomainUnloadedException>(() => plug1.GetFields());
            Assert.Throws <AppDomainUnloadedException>(() => plug1.Close());
            Assert.Throws <AppDomainUnloadedException>(() => plug2.GetFields());
            Assert.Throws <AppDomainUnloadedException>(() => plug2.Close());
        }
Exemple #15
0
        public void LoadedPluginNotInCurrentAppDomain()
        {
            var col               = new PluginsCollection();
            var plug1             = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);
            var currentAssemblies = AppDomain.CurrentDomain.GetAssemblies();
            var foundAssembly     =
                currentAssemblies.Where(
                    x =>
                    x.FullName == plug1.ToString() ||
                    x.GetType().FullName == plug1.TypeFullName);

            Assert.NotNull(plug1);
            Assert.Equal(foundAssembly.Count(), 0);
        }
Exemple #16
0
        public void LoadPluginByBadAssembly()
        {
            var col = new PluginsCollection();

            Assert.Throws <PluginsException>(() => col.LoadPlugin("badAsm"));
        }
Exemple #17
0
        public void LoadPluginByAsmAndBadName()
        {
            var col = new PluginsCollection();

            Assert.Throws <TypeLoadException>(() => col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, "badfullname"));
        }
Exemple #18
0
        public void LoadPluginByBadAsmAndName()
        {
            var col = new PluginsCollection();

            Assert.Throws <PluginsException>(() => col.LoadPlugin("Sosososbad", TEST_PLUGIN1_FULLNAME));
        }
 public void LoadPluginByAsmAndMissingName()
 {
     var col = new PluginsCollection();
     Assert.Throws<PluginsException>(() => col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, null));
 }
 public void LoadPluginByMissingAsmAndName()
 {
     var col = new PluginsCollection();
     Assert.Throws<PluginsException>(() => col.LoadPlugin(null, TEST_PLUGIN1_FULLNAME));
 }
 public void LoadPluginByBadAsmAndName()
 {
     var col = new PluginsCollection();
     Assert.Throws<PluginsException>(() => col.LoadPlugin("Sosososbad", TEST_PLUGIN1_FULLNAME));
 }
Exemple #22
0
        public void LoadPluginByAsmAndMissingName()
        {
            var col = new PluginsCollection();

            Assert.Throws <PluginsException>(() => col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, null));
        }
        public void LoadAndCheckContainsPlugin()
        {
            var col = new PluginsCollection();
            col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.True(col.Contains(TEST_PLUGIN1_FULLNAME));
            Assert.False(col.Contains("fsefsefse"));
        }
 public void LoadPluginByBadAssembly()
 {
     var col = new PluginsCollection();
     Assert.Throws<PluginsException>(() => col.LoadPlugin("badAsm"));
 }
 public void LoadAndSelectPlugin()
 {
     var col = new PluginsCollection();
     var plug1 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);
     var plug2 = col[TEST_PLUGIN1_FULLNAME].FirstOrDefault();
     
     Assert.Equal(plug1, plug2);
     Assert.Equal(plug1, plug2);
 }
        public void LoadedPluginNotInCurrentAppDomain()
        {
            var col = new PluginsCollection();
            var plug1 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);
            var currentAssemblies = AppDomain.CurrentDomain.GetAssemblies();
            var foundAssembly =
                currentAssemblies.Where(
                    x =>
                        x.FullName == plug1.ToString() ||
                        x.GetType().FullName == plug1.TypeFullName);

            Assert.NotNull(plug1);
            Assert.Equal(foundAssembly.Count(), 0);
        }
        public void LoadTwoSamePlugins()
        {
            var col = new PluginsCollection();
            var plug1 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);
            var plug2 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.NotNull(plug1);
            Assert.NotNull(plug2);
            Assert.NotEqual(plug1.GetHashCode(), plug2.GetHashCode());
            Assert.NotEqual(plug1.GetHashCode(), plug2.GetHashCode());
            Assert.Equal(col.Count(), 2);
        }
        public void LoadAndRemovePluginAndGCCollect()
        {
            var col = new PluginsCollection();
            var plug = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.NotNull(plug);
            Assert.True(col.Any());

            col.RemovePlugin(plug);
            Assert.Equal(col.Count(), 0);

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            Assert.Throws<AppDomainUnloadedException>(() => plug.GetFields());
            Assert.Throws<AppDomainUnloadedException>(() => plug.Close());
        }
 public void LoadPluginByAsmAndBadName()
 {
     var col = new PluginsCollection();
     Assert.Throws<TypeLoadException>(() => col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, "badfullname"));
 }
        public void LoadAndUsingPluginsWithGCCollect()
        {
            var col = new PluginsCollection();
            var plug1 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);
            var plug2 = col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, TEST_PLUGIN1_FULLNAME);

            Assert.NotNull(plug1);
            Assert.NotNull(plug2);
            Assert.Equal(col.Count(), 2);

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            Assert.DoesNotThrow(() => plug1.GetFields());
            Assert.DoesNotThrow(plug1.Close);
            Assert.DoesNotThrow(() => plug2.GetFields());
            Assert.DoesNotThrow(plug2.Close);
        }
Exemple #31
0
        public void LoadPluginByMissingAsmAndName()
        {
            var col = new PluginsCollection();

            Assert.Throws <PluginsException>(() => col.LoadPlugin(null, TEST_PLUGIN1_FULLNAME));
        }