Beispiel #1
0
        public void DirectoryXmlTest_CreateInstance_Success()
        {
            // arrange
            DirectoryXml directory;

            // act
            directory = new DirectoryXml();

            // assert
            Assert.IsNotNull( directory );
            Assert.IsInstanceOf<DirectoryXml>( directory );
        }
Beispiel #2
0
        public void Equals_AreEqual_Success()
        {
            // arrange
            DirectoryXml dirOne = new DirectoryXml();
            DirectoryXml dirTwo = new DirectoryXml();
            string location = Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
            dirOne.Location = location;
            dirTwo.Location = location;

            // act

            // assert
            Assert.AreEqual( dirOne, dirTwo );
        }
        public void Equals_DifferentDependenciesLength_AreNotEqual()
        {
            // arrange
            DependenciesConfigXml configOne = new DependenciesConfigXml();
            DependenciesConfigXml configTwo = new DependenciesConfigXml();
            DirectoryXml dir = new DirectoryXml();
            dir.Location = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
            configOne.Dependencies = new System.Collections.ObjectModel.Collection<DirectoryXml>();
            configOne.Dependencies.Add( dir );
            configTwo.Dependencies = new System.Collections.ObjectModel.Collection<DirectoryXml>();
            configTwo.Dependencies.Add( dir );
            configTwo.Dependencies.Add( dir );
            bool areEqual;

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

            // assert
            Assert.IsFalse( areEqual );
        }
        public void GetHashCode_EqualObjects_SameHashCodes()
        {
            // arrange
            DependenciesConfigXml configOne = new DependenciesConfigXml();
            DependenciesConfigXml configTwo = new DependenciesConfigXml();
            DirectoryXml dir = new DirectoryXml();
            dir.Location = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
            configOne.Dependencies = new System.Collections.ObjectModel.Collection<DirectoryXml>();
            configOne.Dependencies.Add( dir );
            configTwo.Dependencies = new System.Collections.ObjectModel.Collection<DirectoryXml>();
            configTwo.Dependencies.Add( dir );
            int hashCodeOne, hashCodeTwo;

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

            // assert
            Assert.AreEqual( hashCodeOne, hashCodeTwo );
        }
Beispiel #5
0
        public void Equals_DifferentLocations_NotEqual()
        {
            // arrange
            DirectoryXml dirOne = new DirectoryXml();
            DirectoryXml dirTwo = new DirectoryXml();
            dirOne.Location = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            dirTwo.Location = Path.GetPathRoot( dirOne.Location );

            // act

            // assert
            Assert.AreNotEqual( dirOne, dirTwo );
        }
Beispiel #6
0
        public void IsInitialized_LocationNull_NotInitialized()
        {
            // arrange
            DirectoryXml directory = new DirectoryXml();
            directory.Location = null;

            // act

            // assert
            Assert.IsFalse( directory.IsInitialized );
        }
Beispiel #7
0
        public void IsInitialized_LocationInitialized_Success()
        {
            // arrange
            DirectoryXml directory = new DirectoryXml();
            directory.Location = Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );

            // act

            // assert
            Assert.IsTrue( directory.IsInitialized );
        }
Beispiel #8
0
        public void GetHashCode_EqualObjects_SameHashcode()
        {
            // arrange
            string location = Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
            DirectoryXml directoryOne = new DirectoryXml();
            DirectoryXml directoryTwo = new DirectoryXml();
            directoryOne.Location = location;
            directoryTwo.Location = location;

            // act

            // assert
            Assert.IsTrue( directoryOne.Equals( directoryTwo ) );
        }
Beispiel #9
0
        public void Equals_DifferentType_NotEqual()
        {
            // arrange
            DirectoryXml dirOne = new DirectoryXml();
            object dirTwoInvalid = new object();

            // act

            // assert
            Assert.AreNotEqual( dirOne, dirTwoInvalid );
        }
Beispiel #10
0
        private DependenciesConfigXml CreateMockDependenciesConfig( params string[] probingDirectories )
        {
            DependenciesConfigXml result = new DependenciesConfigXml();
            result.Dependencies = new Collection<DirectoryXml>();

            foreach ( string probingDir in probingDirectories )
            {
                DirectoryXml dirXml = new DirectoryXml();
                dirXml.Location = probingDir;
                result.Dependencies.Add( dirXml );
            }

            return result;
        }