Exemplo n.º 1
0
        public void Equals_DifferentDependenciesLength_AreNotEqual()
        {
            // arrange
            PluginsConfigXml configOne = new PluginsConfigXml();
            PluginsConfigXml configTwo = new PluginsConfigXml();
            FileXml file = new FileXml();
            file.Location = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
            configOne.PlugIns = new System.Collections.ObjectModel.Collection<FileXml>();
            configOne.PlugIns.Add( file );
            configTwo.PlugIns = new System.Collections.ObjectModel.Collection<FileXml>();
            configTwo.PlugIns.Add( file );
            configTwo.PlugIns.Add( file );
            bool areEqual;

            // act
            areEqual = configOne.Equals( configTwo );

            // assert
            Assert.IsFalse( areEqual );
        }
Exemplo n.º 2
0
        private PluginsConfigXml CreatePluginsConfigMock( params string[] pluginFilePaths )
        {
            PluginsConfigXml result = new PluginsConfigXml();

            result.PlugIns = new System.Collections.ObjectModel.Collection<FileXml>();
            foreach ( string filePath in pluginFilePaths )
            {
                FileXml fileXml = new FileXml();
                fileXml.FileName = Path.GetFileName( filePath );
                fileXml.Location = Path.GetDirectoryName( filePath );
                result.PlugIns.Add( fileXml );
            }

            return result;
        }
Exemplo n.º 3
0
        public void GetPluginsForType_ValidExistentPluginType2Results_Returns2Results()
        {
            // arrange
            ILogManager lmMock = this.CreateLogManagerMock();
            PluginsConfigXml config = this.CreatePluginsConfigMock();
            FileXml pluginFile = new FileXml();
            pluginFile.FileName = Path.GetFileName( Assembly.GetExecutingAssembly().Location );
            pluginFile.Location = Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location );
            config.PlugIns.Add( pluginFile );
            PluginManager pm = new PluginManager( lmMock, config );
            IEnumerable<Attribute> pluginsOne = null;
            IEnumerable<Attribute> pluginsTwo = null;

            // act
            pluginsOne = pm.GetPluginsForType( typeof( TestPluggableOne ) );
            pluginsTwo = pm.GetPluginsForType( typeof( TestPluggableTwo ) );

            // assert
            Assert.IsNotNull( pluginsOne );
            Assert.AreEqual( 2, pluginsOne.Count<Attribute>() );
            Assert.IsNotNull( pluginsTwo );
            Assert.AreEqual( 1, pluginsTwo.Count<Attribute>() );
        }
Exemplo n.º 4
0
        public void IsInitialized_FileNameNull_NotInitialized()
        {
            // arrange
            FileXml file = new FileXml();
            file.FileName = null;

            // act

            // assert
            Assert.IsFalse( file.IsInitialized );
        }
Exemplo n.º 5
0
        public void IsInitialized_FileNameLocationInitialized_Success()
        {
            // arrange
            FileXml file = new FileXml();
            file.FileName = "test";
            file.Location = "test";

            // act

            // assert
            Assert.IsTrue( file.IsInitialized );
        }
Exemplo n.º 6
0
        public void IsInitialized_FileNameEmpty_NotInitialized()
        {
            // arrange
            FileXml file = new FileXml();
            file.FileName = string.Empty;
            file.Location = "test";

            // act

            // assert
            Assert.IsFalse( file.IsInitialized );
        }
Exemplo n.º 7
0
        public void GetHashCode_EqualObjects_SameHashCode()
        {
            // arrange
            FileXml fileOne = new FileXml();
            FileXml fileTwo = new FileXml();
            fileOne.Location = "something";
            fileTwo.Location = "something";
            fileOne.FileName = "else";
            fileTwo.FileName= "else";

            // act

            // assert
            Assert.AreEqual( fileOne.GetHashCode(), fileTwo.GetHashCode() );
        }
Exemplo n.º 8
0
        public void GetHashCode_DifferentFileNames_DifferentHashCode()
        {
            // arrange
            FileXml fileOne = new FileXml();
            FileXml fileTwo = new FileXml();
            fileOne.Location = "something";
            fileTwo.Location = "something";
            fileOne.FileName = "one";
            fileTwo.FileName = "two";

            // act

            // assert
            Assert.AreNotEqual( fileOne.GetHashCode(), fileTwo.GetHashCode() );
        }
Exemplo n.º 9
0
        public void FileXml_CreateInstance_Success()
        {
            // arrange
            FileXml file;

            // act
            file = new FileXml();

            // assert
            Assert.IsNotNull( file );
            Assert.IsInstanceOf<FileXml>( file );
        }
Exemplo n.º 10
0
        public void Equals_DifferentTypes_NotEqual()
        {
            // arrange
            FileXml fileOne = new FileXml();
            object fileTwoInvalid = new object();

            // act

            // assert
            Assert.AreNotEqual( fileOne, fileTwoInvalid );
        }
Exemplo n.º 11
0
        public void Equals_DifferentFileNames_NotEqual()
        {
            // arrange
            FileXml fileOne = new FileXml();
            FileXml fileTwo = new FileXml();
            fileOne.Location = "something";
            fileTwo.Location = "else";
            fileOne.FileName = "something";
            fileTwo.FileName = "else";

            // act

            // assert
            Assert.AreNotEqual( fileOne, fileTwo );
        }
Exemplo n.º 12
0
        public void Equals_BothFileNamesNull_AreEqual()
        {
            // arrange
            FileXml fileOne = new FileXml();
            FileXml fileTwo = new FileXml();
            fileOne.Location = "something";
            fileTwo.Location = "something";
            fileOne.FileName = null;
            fileTwo.FileName = null;

            // act

            // assert
            Assert.AreEqual( fileOne, fileTwo );
        }
Exemplo n.º 13
0
        public void Equals_BothAreEqual_Success()
        {
            // arrange
            FileXml fileOne = new FileXml();
            FileXml fileTwo = new FileXml();
            fileOne.FileName = "something";
            fileTwo.FileName = fileOne.FileName;
            fileOne.Location = "";
            fileTwo.Location = fileOne.Location;

            // act

            // assert
            Assert.AreEqual( fileOne, fileTwo );
        }
Exemplo n.º 14
0
        public void GetHashCode_EqualObjects_SameHashCodes()
        {
            // arrange
            PluginsConfigXml configOne = new PluginsConfigXml();
            PluginsConfigXml configTwo = new PluginsConfigXml();
            FileXml file = new FileXml();
            file.Location = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
            file.FileName = "abcdef";
            configOne.PlugIns = new System.Collections.ObjectModel.Collection<FileXml>();
            configOne.PlugIns.Add( file );
            configTwo.PlugIns = new System.Collections.ObjectModel.Collection<FileXml>();
            configTwo.PlugIns.Add( file );
            int hashCodeOne, hashCodeTwo;

            // act
            hashCodeOne = configOne.GetHashCode();
            hashCodeTwo = configTwo.GetHashCode();

            // assert
            Assert.AreEqual( hashCodeOne, hashCodeTwo );
        }
Exemplo n.º 15
0
        public void GetHashCode_DifferentDependencies_DifferentHashCodes()
        {
            // arrange
            PluginsConfigXml configOne = new PluginsConfigXml();
            PluginsConfigXml configTwo = new PluginsConfigXml();
            FileXml file = new FileXml();
            FileXml dirOther = new FileXml();
            file.Location = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
            file.FileName = "abcd";
            dirOther.Location = System.IO.Path.GetPathRoot( file.Location );
            dirOther.FileName = "xyz";
            configOne.PlugIns = new System.Collections.ObjectModel.Collection<FileXml>();
            configOne.PlugIns.Add( file );
            configTwo.PlugIns = new System.Collections.ObjectModel.Collection<FileXml>();
            configTwo.PlugIns.Add( file );
            configTwo.PlugIns.Add( dirOther );
            int hashCodeOne, hashCodeTwo;

            // act
            hashCodeOne = configOne.GetHashCode();
            hashCodeTwo = configTwo.GetHashCode();

            // assert
            Assert.AreNotEqual( hashCodeOne, hashCodeTwo );
        }