예제 #1
0
        public void GetSectionDataAs_XmlElement_Success()
        {
            // arrange
            string sectionName = "dependencies";
            ISectionXml testSection = this.CreateSectionMock( sectionName, this.xmlDependenciesConfig, typeof( DependenciesConfigXml ).FullName );
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule", testSection );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );
            XmlElement expectedXml = config.GetSectionCloned( sectionName ).XmlElement;
            XmlElement resultXml = null;

            // act
            resultXml = config.GetSectionDataAs( typeof( XmlElement ), sectionName ) as XmlElement;

            // assert
            Assert.IsNotNull( resultXml );
            Assert.AreEqual( expectedXml, resultXml );
        }
예제 #2
0
        public void GetSectionDataAs_ValidSectionString_GetDataRawXml()
        {
            // arrange
            string sectionName = "plugins";
            ISectionXml testSection = this.CreateSectionMock( sectionName, this.xmlPluginsConfig, typeof( PluginsConfigXml ).FullName );
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule", testSection );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );

            string expectedXml = config.GetSectionCloned( sectionName ).XmlRaw;
            string resultData = null;

            // act
            resultData = config.GetSectionDataAs( typeof( string ), sectionName ) as string;

            // assert
            Assert.IsNotNull( resultData );
            Assert.AreEqual( expectedXml, resultData );
        }
예제 #3
0
        public void GetSectionDataAs_InvalidConfigDataType_RaisePluginNotFoundException()
        {
            // arrange
            ISectionXml testSection = this.CreateSectionMock( "plugins", this.xmlPluginsConfig, typeof( PluginsConfigXml ).FullName );
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule", testSection );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );
            string sectionName = "plugins";
            Type invalidType = typeof( MemoryStream );

            // act
            config.GetSectionDataAs( invalidType, sectionName );

            // assert
        }
예제 #4
0
        public void GetSectionDataAs_InvalidSectionString_RaiseArgumentException()
        {
            // arrange
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule" );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );
            string sectionName = Guid.NewGuid().ToString();
            string resultData = null;

            // act
            resultData = config.GetSectionDataAs( typeof( string ), sectionName ) as string;

            // assert
        }
예제 #5
0
        public void GetSectionDataAs_ConfigDataTypeNull_RaiseArgumentNullExcpetion()
        {
            // arrange
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule" );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );
            string sectionName = "plugins";
            Type typeNull = null;

            // act
            config.GetSectionDataAs( typeNull, sectionName );

            // assert
        }