Esempio n. 1
0
        public void AddProbingPath_DirectoryInfoIsNull_RaiseArgumentException()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            DirectoryInfo directory = null;

            // act
            dr.AddProbingPath( directory, false );

            // assert
        }
Esempio n. 2
0
        public void AddProbingPath_InvalidDirectoryInfo_RaiseDirectoryNotFoundException()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            string directoryPath = "pathdoesnotexist";
            DirectoryInfo directory = new DirectoryInfo( directoryPath );

            // act
            dr.AddProbingPath( directory, false );

            // assert
        }
Esempio n. 3
0
        public void AddProbingPath_DirectoryPathInvalid_RaiseArgumentException()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            string invalidDir = Path.GetInvalidFileNameChars()[ 0 ] + @"§$%&/";

            // act
            dr.AddProbingPath( invalidDir, false );

            // assert
        }
Esempio n. 4
0
        public void TryResolveAssemblyDependency_TypeNameNull_RaiseArgumentNulLException()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            Assembly expectedAssembly = Assembly.GetExecutingAssembly();
            string path = Path.GetDirectoryName( expectedAssembly.Location );
            string assemblyName = null;
            dr.AddProbingPath( path, false );
            Assembly resolvedAssembly = null;

            // act
            resolvedAssembly = dr.TryResolveAssemblyDependency( assemblyName );

            // assert
        }
Esempio n. 5
0
        public void TryResolveAssemblyDependency_ResolveKnownAssembly_RaiseBadImageFormatException()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            Assembly expectedAssembly = Assembly.GetExecutingAssembly();
            string path = Path.GetDirectoryName( expectedAssembly.Location );
            string assemblyName = "InvalidDLL";
            dr.AddProbingPath( path, false );
            Assembly resolvedAssembly = null;

            // act
            resolvedAssembly = dr.TryResolveAssemblyDependency( assemblyName );

            // assert
        }
Esempio n. 6
0
        public void TryResolveAssemblyDependency_ResolveKnownAssembly_Success()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            Assembly expectedAssembly = Assembly.GetExecutingAssembly();
            string path = Path.GetDirectoryName( expectedAssembly.Location );
            string assemblyName = expectedAssembly.FullName;
            dr.AddProbingPath( path, false );
            Assembly resolvedAssembly = null;

            // act
            resolvedAssembly = dr.TryResolveAssemblyDependency( assemblyName );

            // assert
            Assert.IsNotNull( resolvedAssembly );
            Assert.AreEqual( expectedAssembly, resolvedAssembly );
        }
Esempio n. 7
0
        public void DependencyResolver_CreateInstance_Success()
        {
            // arrange
            DependencyResolver dr;

            // act
            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            dr = new DependencyResolver( dcMock );

            // assert
            Assert.IsNotNull( dr );
            Assert.IsInstanceOf<DependencyResolver>( dr );
        }
Esempio n. 8
0
        public void ProbingPaths_Get_Success()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            string path1 = ".";
            string path2 = "..";
            dr.AddProbingPath( path1, false );
            dr.AddProbingPath( path2, false );

            // act
            var probingPaths = dr.ProbingPaths;

            // assert
            Assert.IsNotNull( probingPaths );
            Assert.IsNotEmpty( probingPaths );
            Assert.AreEqual( 2, probingPaths.Count );
            Assert.IsTrue( probingPaths.Contains( Path.GetFullPath( path1 ) ) );
            Assert.IsTrue( probingPaths.Contains( Path.GetFullPath( path2 ) ) );
        }
Esempio n. 9
0
        public void ClearProbingPaths_AddTwoThenClear_NoPathsLeft()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            dr.AddProbingPath( ".", false );
            dr.AddProbingPath( "..", false );

            // act
            dr.ClearProbingPaths();

            // assert
            Assert.IsEmpty( dr.ProbingPaths );
        }
Esempio n. 10
0
        public void AddProbingPath_ValidPathString_Success()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            string probingPath = ".";

            // act
            dr.AddProbingPath( probingPath, false );

            // assert
            dr.ProbingPaths.Contains( probingPath );
        }
Esempio n. 11
0
        public void AddProbingPath_ValidDirectoryInfo_Success()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            string probingPath = ".";
            System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo( probingPath );

            // act
            dr.AddProbingPath( directory, false );

            // assert
            dr.ProbingPaths.Contains( directory.FullName );
        }
Esempio n. 12
0
        public void AddProbingPath_ProbingPathAlreadyAdded_RaiseArgumentException()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            string directoryPath = ".";
            DirectoryInfo directory = new DirectoryInfo( directoryPath );

            // act
            dr.AddProbingPath( directory, false );
            dr.AddProbingPath( directory, false );

            // assert
        }
Esempio n. 13
0
        public void AddProbingPath_PathIsNull_RaiseArgumentException()
        {
            // arrange

            DependenciesConfigXml dcMock = this.CreateMockDependenciesConfig();
            DependencyResolver dr = new DependencyResolver( dcMock );
            string path = null;

            // act
            dr.AddProbingPath( path, false );

            // assert
        }