public void InsertDataSectionIntoSectionXml_XmlDoesNotMatchType_RaiseCoreConfigException()
        {
            // arrange
            Type expectedType = typeof( DependenciesConfigXml );
            Type actualType = null;
            SectionXml testSection = new SectionXml();
            testSection.Name = "testSection";
            // fill in xml that does not match type
            testSection.XmlElement = this.xmlRandom;
            testSection.DataTypeName = expectedType.FullName;
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule", testSection );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );

            // act
            actualType = config.InsertDataIntoSectionXml( testSection );

            // assert
        }
        public void InsertDataSectionIntoSectionXml_SectionNull_RaiseArgumentNullException()
        {
            // arrange
            Type actualType = null;
            SectionXml testSection = null;
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule", testSection );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );

            // act
            actualType = config.InsertDataIntoSectionXml( testSection );

            // assert
        }
        public void InsertDataSectionIntoSectionXml_DataTypePluginsConfig_Success()
        {
            // arrange
            Type expectedType = typeof( PluginsConfigXml );
            Type actualType = null;
            SectionXml testSection = new SectionXml();
            testSection.Name = "testSection";
            testSection.XmlElement = this.xmlPluginsConfig;
            testSection.DataTypeName = expectedType.FullName;
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule", testSection );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );

            // act
            actualType = config.InsertDataIntoSectionXml( testSection );

            // assert
            Assert.AreEqual( expectedType, actualType );
            Assert.IsNotNull( testSection.Data );
            Assert.IsInstanceOf( expectedType, testSection.Data );
            Assert.IsTrue( ( ( PluginsConfigXml ) testSection.Data ).IsInitialized );
        }
        public void InsertDataSectionIntoSectionXml_DefaultDataTypeXmlElement_Success()
        {
            // arrange
            ISectionXml testSection = this.CreateSectionMock( "testSection", this.xmlPluginsConfig, typeof(XmlElement).FullName );
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule", testSection );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );
            Type expectedType = typeof( XmlElement );
            Type actualType = null;

            // act
            actualType = config.InsertDataIntoSectionXml( testSection as SectionXml );

            // assert
            Assert.AreEqual( expectedType, actualType );
            Assert.IsNotNull( testSection.Data );
            Assert.IsInstanceOf( expectedType, testSection.Data );
            Assert.AreEqual( testSection.XmlElement, testSection.Data );
            Assert.AreEqual( testSection.XmlRaw, ( ( XmlElement ) testSection.Data ).OuterXml );
        }
        public void InsertDataSectionIntoSectionXml_DataTypeNotDefined_RaisePluginNotFoundException()
        {
            // arrange
            Type expectedType = typeof( DependenciesConfigXml );
            Type actualType = null;
            SectionXml testSection = new SectionXml();
            testSection.Name = "testSection";
            testSection.XmlElement = this.xmlDependenciesConfig;
            // define invalid type name
            testSection.DataTypeName = "Something.Went.Wrong.ConfigType";
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule", testSection );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );

            // act
            actualType = config.InsertDataIntoSectionXml( testSection );

            // assert
        }