public void CloneSectionWithData_SectionNull_RaiseArgumentNullException() { // arrange IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule" ); NGinModuleConfig config = new NGinModuleConfig( moduleMock ); ISectionXml sectionNull = null; // act config.CloneSectionWithData( sectionNull ); // assert }
public NGinConfig( string configFile ) { this.nginConfig = this.DeserializeConfigFile( configFile ); DependenciesConfigXml dependenciesConfig = this.DeserializeDependenciesConfig( nginConfig ); this.DependencyResolver = new DependencyResolver( dependenciesConfig ); foreach ( IModuleXml module in this.nginConfig.Modules ) { INGinModuleConfig moduleConfig = new NGinModuleConfig( module ); this.modules.Add( moduleConfig.Name, moduleConfig ); } }
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_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_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 }
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() ); }
public void GetSectionData_UnknownSection_RaiseArgumentException() { // arrange IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule" ); NGinModuleConfig config = new NGinModuleConfig( moduleMock ); string sectionName = Guid.NewGuid().ToString(); object data = null; // act data = config.GetSectionData( sectionName ); // assert }
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 ); }
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_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_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 }
public void GetSectionDataAsXmlElement_InvalidSection_RaiseArgumentException() { // arrange IModuleXml moduleMock = this.CreateModuleMock( "testModule", "NGin.Core.Test.NGinModuleConfigTest.TestModule" ); NGinModuleConfig config = new NGinModuleConfig( moduleMock ); string sectionName = Guid.NewGuid().ToString(); XmlElement resultXml = null; // act resultXml = config.GetSectionDataAsXmlElement( sectionName ); // assert }
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 ); }
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 }
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 }
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_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 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 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 ); }
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 ); }