Example #1
0
        public void GetPluggables_ListNull_RaiseArgumentNullException()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            PluginManager pm = new PluginManager( lmMock, config );
            IList<Assembly> assemblyList = null;

            // act
            pm.GetPluggables( assemblyList );

            // assert
        }
Example #2
0
        public void GetPluggables_ValidListOneEntryIsNull_RaiseInvalidOperationException()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            PluginManager pm = new PluginManager( lmMock, config );
            Assembly testAssembly = null;
            IList<Assembly> assemblyList = new List<Assembly>();
            assemblyList.Add( testAssembly );
            IList<Type> pluggables = null;

            // act
            pm.GetPluggables( assemblyList );

            // assert
        }
Example #3
0
        public void PluginManager_ValidLogManagerValidConfigNoPlugins_Success()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml configMock = this.CreatePluginsConfigMock();
            PluginManager pm = null;

            // act
            pm = new PluginManager( lmMock, configMock );

            // assert
            Assert.IsNotNull( pm );
            Assert.IsInstanceOf<PluginManager>( pm );
        }
Example #4
0
        public void PluginManager_LogManagerNullValidConfigNoPlugins_RaiseArgumentNullException()
        {
            // arrange
            ILogManager lmNull = null;
            PluginsConfigXml configMock = this.CreatePluginsConfigMock();
            PluginManager pm = null;

            // act
            pm = new PluginManager( lmNull, configMock );

            // assert
        }
Example #5
0
        public void PluginManager_ValidLogManagerConfigNull_RaiseArgumentNullException()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml configNull = null;
            PluginManager pm = null;

            // act
            pm = new PluginManager( lmMock, configNull );

            // assert
        }
Example #6
0
        public void GetPlugins_ValidPluggablesEmptyAssembliesNull_RaiseArgumentNullException()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            PluginManager pm = new PluginManager( lmMock, config );
            IList<Type> pluggables = new List<Type>();
            IList<Assembly> pluginAssemblies = null;
            Dictionary<Type, IList<Attribute>> plugins = null;

            // act
            plugins = pm.GetPlugins( pluggables, pluginAssemblies );

            // assert
        }
Example #7
0
        public void GetPlugins_ValidPluggablesEmptyValidAssembliesEmpty_0Plugins()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            PluginManager pm = new PluginManager( lmMock, config );
            IList<Type> pluggables = new List<Type>();
            IList<Assembly> pluginAssemblies = new List<Assembly>();
            Dictionary<Type, IList<Attribute>> plugins = null;

            // act
            plugins = pm.GetPlugins( pluggables, pluginAssemblies );

            // assert
            Assert.IsNotNull( plugins );
            Assert.AreEqual( 0, plugins.Count );
        }
Example #8
0
        public void GetPluginsForType_ValidExistentPluginType2Results_Returns2Results()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            FileXml pluginFile = new FileXml();
            pluginFile.FileName = Path.GetFileName( Assembly.GetExecutingAssembly().Location );
            pluginFile.Location = Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location );
            config.PlugIns.Add( pluginFile );
            PluginManager pm = new PluginManager( lmMock, config );
            IEnumerable<Attribute> pluginsOne = null;
            IEnumerable<Attribute> pluginsTwo = null;

            // act
            pluginsOne = pm.GetPluginsForType( typeof( TestPluggableOne ) );
            pluginsTwo = pm.GetPluginsForType( typeof( TestPluggableTwo ) );

            // assert
            Assert.IsNotNull( pluginsOne );
            Assert.AreEqual( 2, pluginsOne.Count<Attribute>() );
            Assert.IsNotNull( pluginsTwo );
            Assert.AreEqual( 1, pluginsTwo.Count<Attribute>() );
        }
Example #9
0
        public void GetPlugins_TwoPluggablesOneAssembly_2PluginTypes2TestPluggableOne1TestPlugggableTwo()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            PluginManager pm = new PluginManager( lmMock, config );
            IList<Type> pluggables = new List<Type>() { typeof( TestPluggableOne ), typeof( TestPluggableTwo ) };
            IList<Assembly> pluginAssemblies = new List<Assembly>() { Assembly.GetExecutingAssembly() };
            Dictionary<Type, IList<Attribute>> plugins = null;

            // act
            plugins = pm.GetPlugins( pluggables, pluginAssemblies );

            // assert
            Assert.IsNotNull( plugins );
            Assert.AreEqual( 2, plugins.Count );
            Assert.AreEqual( 2, plugins[ typeof( TestPluggableOne ) ].Count );
            Assert.AreEqual( 1, plugins[ typeof( TestPluggableTwo ) ].Count );
        }
Example #10
0
        public void GetPluginAssemblies_ValidConfigNoPlugins_0Assemblies()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            PluginManager pm = new PluginManager( lmMock, config );
            IList<Assembly> assemblies = null;

            // act
            assemblies = pm.GetPluginAssemblies( config );

            // assert
            Assert.IsNotNull(assemblies);
            Assert.AreEqual( 0, assemblies.Count );
        }
Example #11
0
        public void GetPluginAssemblies_ValidConfig2Plugins_2Assemblies()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            PluginManager pm = new PluginManager( lmMock, config );
            string pluginOnePath = Assembly.GetExecutingAssembly().Location;
            string pluginTwoPath = Assembly.GetExecutingAssembly().Location;
            PluginsConfigXml config2Plugins = this.CreatePluginsConfigMock( pluginOnePath, pluginTwoPath );
            IList<Assembly> assemblies = null;

            // act
            assemblies = pm.GetPluginAssemblies( config2Plugins );

            // assert
            Assert.IsNotNull( assemblies );
            Assert.AreEqual( 2, assemblies.Count );
        }
Example #12
0
        public void GetPluginAssemblies_ConfigPluginsListNull_RaiseInvalidOperationException()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            PluginManager pm = new PluginManager( lmMock, config );
            PluginsConfigXml configInvalid = this.CreatePluginsConfigMock();
            configInvalid.PlugIns = null;

            // act
            pm.GetPluginAssemblies( configInvalid );

            // assert
        }
Example #13
0
        public void GetPluginAssemblies_ConfigNull_RaiseArgumentNullException()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            PluginManager pm = new PluginManager( lmMock, config );
            PluginsConfigXml configNull = null;

            // act
            pm.GetPluginAssemblies( configNull );

            // assert
        }
Example #14
0
        public void GetPluggables_ValidListTestAssembly_2Pluggables()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            PluginManager pm = new PluginManager( lmMock, config );
            Assembly testAssembly = Assembly.GetExecutingAssembly();
            IList<Assembly> assemblyList = new List<Assembly>();
            assemblyList.Add( testAssembly );
            IList<Type> pluggables = null;

            // act
            pluggables = pm.GetPluggables( assemblyList );

            // assert
            Assert.IsNotNull( pluggables );
            Assert.AreEqual( 2, pluggables.Count );
            Assert.AreEqual( typeof(TestPluggableOne), pluggables[0] );
            Assert.AreEqual( typeof(TestPluggableTwo), pluggables[1] );
        }