Beispiel #1
0
        public void Load_ValidAssemblyPath_LoadsAssemblyFromPath()
        {
            // TODO: check if we can use Smocks to unit test Smocks itself.
            // Currently we cannot mock Assembly.LoadFrom so we resort
            // to actually loading an assembly in a temporary appdomain.
            string assemblyName      = Guid.NewGuid().ToString();
            string dummyAssemblyPath = AssemblyUtility.CreateDummyAssembly(new AssemblyName(assemblyName));

            AppDomainUtility.InvokeInOtherAppDomain(dummyAssemblyPath, assemblyName, (path, name) =>
            {
                // Act
                var subject = new AssemblyLoader(path);
                var result  = subject.Load();

                // Assert
                Assert.NotNull(result);
                Assert.AreEqual(name, result.GetName().Name);
                Assert.AreEqual(path, result.Location);
            });

            // Cleanup
            File.Delete(dummyAssemblyPath);
        }