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 ); }
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 ); }
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 }
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 }
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 }