Ejemplo n.º 1
0
        public void CloneSectionWithData_ValidSection_DataValid()
        {
            // 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 );
            ISectionXml section = config.GetSectionCloned( "plugins" );
            ISectionXml clone = null;

            // act
            clone = config.CloneSectionWithData( section );

            // assert
            Assert.IsNotNull( clone );
            Assert.IsInstanceOf<ISectionXml>( clone );
            Assert.AreNotSame( section, clone );
            Assert.AreEqual( section, clone );
        }
Ejemplo n.º 2
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 );
        }
Ejemplo n.º 3
0
        public void GetSectionData_ValidSection_DataValid()
        {
            // arrange
            Type expectedType = typeof( PluginsConfigXml );
            ISectionXml testSection = this.CreateSectionMock( "plugins", this.xmlPluginsConfig, expectedType.FullName );
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule", testSection );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );
            string sectionName = "plugins";
            ISectionXml expectedSection = config.GetSectionCloned( sectionName );
            object data = null;

            // act
            data = config.GetSectionData( sectionName );

            // assert
            Assert.IsNotNull( data );
            Assert.IsInstanceOf( expectedType, data );
            Assert.AreEqual( expectedSection.Data, data );
            Assert.AreEqual( expectedSection.DataType, data.GetType() );
        }
Ejemplo n.º 4
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 );
        }
Ejemplo n.º 5
0
        public void GetSectionDataAsRawXml_ValidSection_Sucess()
        {
            // 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 expectedXml = config.GetSectionCloned( "plugins" ).XmlRaw;
            string resultXml = null;

            // act
            resultXml = config.GetSectionDataAsRawXml( "plugins" );

            // assert
            Assert.IsNotNull( resultXml );
            Assert.AreEqual( expectedXml, resultXml );
        }
Ejemplo n.º 6
0
        public void GetSectionCloned_SectionNull_RaiseArgumentNullException()
        {
            // arrange
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule" );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );
            string sectionNameNull = null;
            ISectionXml section = null;

            // act
            section = config.GetSectionCloned( sectionNameNull );

            // assert
        }
Ejemplo n.º 7
0
        public void GetSectionCloned_SectionNotExist_RaiseArgumentException()
        {
            // arrange
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule" );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );
            string invalidSectionName = Guid.NewGuid().ToString();
            ISectionXml section = null;

            // act
            section = config.GetSectionCloned( invalidSectionName );

            // assert
        }
Ejemplo n.º 8
0
        public void GetSectionCloned_GetSameSectionTwice_ResultNotSameRef()
        {
            // arrange
            Type expectedType = typeof( DependenciesConfigXml );
            SectionXml testSection = new SectionXml();
            testSection.Name = "testSection";
            // fill in xml that does not match type
            testSection.XmlElement = this.xmlDependenciesConfig;
            testSection.DataTypeName = expectedType.FullName;
            IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule", testSection );
            NGinModuleConfig config = new NGinModuleConfig( moduleMock );
            ISectionXml first = null;
            ISectionXml second = null;

            // act
            first = config.GetSectionCloned( testSection.Name );
            second = config.GetSectionCloned( testSection.Name );

            // assert
            Assert.IsNotNull( first );
            Assert.IsNotNull( second );
            Assert.AreNotSame( first, second );
            Assert.AreEqual( first, second );
        }