Example #1
0
        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
        }
Example #2
0
        private ISectionXml CreateSectionMock(string sectioName, XmlElement sectionDataXml, string sectionTypeName )
        {
            SectionXml result = new SectionXml();
            result.Name = sectioName;
            result.XmlElement = sectionDataXml;
            result.DataTypeName = sectionTypeName;

            return result;
        }
Example #3
0
        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
        }
Example #4
0
        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 );
        }
Example #5
0
        public object Clone()
        {
            SectionXml clone = new SectionXml();
            clone.DataType = this.DataType;
            clone.DataTypeName = this.DataTypeName;
            clone.Name = this.Name;
            clone.XmlElement = this.XmlElement;

            return clone;
        }
Example #6
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 );
        }
Example #7
0
        public void GetHashCode_EqualNames_SameHashCode()
        {
            // arrange
            string name = "rolf";
            SectionXml original = new SectionXml();
            original.Name = name;
            SectionXml other = new SectionXml();
            other.Name = name;

            // act

            // assert
            Assert.AreEqual( original.GetHashCode(), other.GetHashCode() );
        }
Example #8
0
        public void SectionXml_CreateInstance_Success()
        {
            // arrange
            SectionXml section;

            // act
            section = new SectionXml();

            // assert
            Assert.IsNotNull( section );
            Assert.IsInstanceOf<SectionXml>( section );
        }
Example #9
0
        public void Equals_XmlNull_AreEqual()
        {
            // arrange
            SectionXml original = new SectionXml();
            SectionXml other = new SectionXml();
            original.Name = "plugins";
            other.Name = original.Name;
            original.XmlElement = null;
            other.XmlElement = null;
            original.DataType = typeof( PluginsConfigXml );
            original.DataTypeName = original.DataType.FullName;
            other.DataType = original.DataType;
            other.DataTypeName = original.DataTypeName;
            original.Data = this.xmlPlugins;
            other.Data = original.Data;

            // act

            // assert
            Assert.AreEqual( original, other );
        }
Example #10
0
        public void GetHashCode_DifferentNames_DifferentHashCode()
        {
            // arrange
            SectionXml original = new SectionXml();
            original.Name = "rolf";
            SectionXml other = new SectionXml();
            other.Name = "bert";

            // act

            // assert
            Assert.AreNotEqual( original.GetHashCode(), other.GetHashCode() );
        }
Example #11
0
        public void Equals_TypesNull_Equal()
        {
            // arrange
            SectionXml original = new SectionXml();
            SectionXml other = new SectionXml();
            original.Name = "plugins";
            other.Name = original.Name;
            original.XmlElement = this.xmlPlugins;
            other.XmlElement = original.XmlElement;
            original.DataType = null;
            original.DataTypeName = string.Empty;
            other.DataType = null;
            other.DataTypeName = original.DataTypeName;
            original.Data = this.xmlPlugins;
            other.Data = original.Data;

            // act

            // assert
            Assert.AreEqual( original, other );
        }
Example #12
0
        public void Equals_DifferentXml_NotEqual()
        {
            // arrange
            SectionXml original = new SectionXml();
            SectionXml other = new SectionXml();
            original.Name = "plugins";
            other.Name = original.Name;
            original.XmlElement = this.xmlPlugins;
            other.XmlElement = this.xmlDependencies;
            original.DataType = typeof( PluginsConfigXml );
            original.DataTypeName = original.DataType.FullName;
            other.DataType = original.DataType;
            other.DataTypeName = original.DataTypeName;
            original.Data = this.xmlPlugins;
            other.Data = original.Data;

            // act

            // assert
            Assert.AreNotEqual( original, other );
        }
Example #13
0
        public void Equals_DifferentTypes_NotEqual()
        {
            // arrange
            SectionXml section = new SectionXml();
            object sectionInvalid = new object();

            // act

            // assert
            Assert.AreNotEqual( section, sectionInvalid );
        }
Example #14
0
        public void Equals_DifferentTypeNames_NotEqual()
        {
            // arrange
            SectionXml original = new SectionXml();
            SectionXml other = new SectionXml();
            original.Name = "plugins";
            other.Name = original.Name;
            original.XmlElement = this.xmlPlugins;
            other.XmlElement = original.XmlElement;
            original.DataType = typeof( PluginsConfigXml );
            original.DataTypeName = Guid.NewGuid().ToString();
            other.DataType = original.DataType;
            other.DataTypeName = Guid.NewGuid().ToString();
            original.Data = this.xmlPlugins;
            other.Data = original.Data;

            // act

            // assert
            Assert.AreNotEqual( original, other );
        }
Example #15
0
        public void Clone_CloneInstance_AreEqualExceptData()
        {
            // arrange
            SectionXml original = new SectionXml();
            original.Name = "plugins";
            original.XmlElement = this.xmlPlugins;
            original.DataTypeName = typeof( PluginsConfigXml ).FullName;
            original.Data = this.xmlPlugins;
            SectionXml clone = null;

            // act
            clone = original.Clone() as SectionXml;

            // assert
            Assert.IsNotNull(clone);
            Assert.IsNull(clone.Data);
            Assert.AreEqual( original, clone );
            Assert.AreNotSame( original, clone );
        }