コード例 #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);
        }
コード例 #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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #7
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);
        }
コード例 #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"));
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #12
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);
        }
コード例 #13
0
        private void loadAllPlugins()
        {
            checkIfPluginsDirExists();
            var assemblies = getAssembliesToLoad();

            foreach (var assembly in assemblies)
            {
                _pluginsCollection.LoadPlugin(assembly);
            }
            informAboutChange();
        }
コード例 #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());
        }
コード例 #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);
        }
コード例 #16
0
        public void LoadPluginByBadAssembly()
        {
            var col = new PluginsCollection();

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

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

            Assert.Throws <PluginsException>(() => col.LoadPlugin("Sosososbad", TEST_PLUGIN1_FULLNAME));
        }
コード例 #19
0
 public void LoadPluginByAsmAndMissingName()
 {
     var col = new PluginsCollection();
     Assert.Throws<PluginsException>(() => col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, null));
 }
コード例 #20
0
 public void LoadPluginByMissingAsmAndName()
 {
     var col = new PluginsCollection();
     Assert.Throws<PluginsException>(() => col.LoadPlugin(null, TEST_PLUGIN1_FULLNAME));
 }
コード例 #21
0
 public void LoadPluginByBadAsmAndName()
 {
     var col = new PluginsCollection();
     Assert.Throws<PluginsException>(() => col.LoadPlugin("Sosososbad", TEST_PLUGIN1_FULLNAME));
 }
コード例 #22
0
        public void LoadPluginByAsmAndMissingName()
        {
            var col = new PluginsCollection();

            Assert.Throws <PluginsException>(() => col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, null));
        }
コード例 #23
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"));
        }
コード例 #24
0
 public void LoadPluginByBadAssembly()
 {
     var col = new PluginsCollection();
     Assert.Throws<PluginsException>(() => col.LoadPlugin("badAsm"));
 }
コード例 #25
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);
 }
コード例 #26
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);
        }
コード例 #27
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);
        }
コード例 #28
0
        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());
        }
コード例 #29
0
 public void LoadPluginByAsmAndBadName()
 {
     var col = new PluginsCollection();
     Assert.Throws<TypeLoadException>(() => col.LoadPlugin(TEST_PLUGIN1_ASSEMBLY, "badfullname"));
 }
コード例 #30
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);
        }
コード例 #31
0
        public void LoadPluginByMissingAsmAndName()
        {
            var col = new PluginsCollection();

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