Пример #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
        }
Пример #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
        }
Пример #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 );
        }
Пример #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
        }
Пример #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
        }
Пример #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
        }
Пример #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 );
        }
Пример #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>() );
        }
Пример #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 );
        }
Пример #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 );
        }
Пример #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 );
        }
Пример #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
        }
Пример #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
        }
Пример #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] );
        }