public void FromAssembly_NullArgument()
 {
     Assert.Throws(typeof(ArgumentNullException), () =>
     {
         var target = AssemblyTarget.FromAssembly(null);
     });
 }
        public void FromAssembly_CurrentAssembly()
        {
            var assembly = Assembly.GetExecutingAssembly();
            var target   = AssemblyTarget.FromAssembly(assembly);

            Assert.NotNull(target);
            Assert.Equal(assembly.CodeBase, target.CodeBase.ToString());
            Assert.Equal(assembly.Location, target.Location);
            Assert.Equal(assembly.FullName, target.FullName);
        }
Beispiel #3
0
        public void if_you_have_the_assembly_directly_just_load()
        {
            var registration = MockRepository.GenerateMock <IAssemblyRegistration>();

            var theAssembly = GetType().Assembly;
            var target      = AssemblyTarget.FromAssembly(theAssembly);

            target.Load(registration);

            registration.AssertWasCalled(x => x.Use(theAssembly));
            registration.AssertWasNotCalled(x => x.LoadFromFile(null, null), x => x.IgnoreArguments());
        }
Beispiel #4
0
        public void LoadTarget_NoRefAssembly_LoadBits()
        {
            using (var context = AppDomainContext.Create())
            {
                var targetPath = Path.GetFullPath(NoRefsAssemblyPath);
                var assembly   = Assembly.LoadFile(targetPath);
                var target     = AssemblyTarget.FromAssembly(assembly);

                context.LoadTarget(LoadMethod.LoadBits, target);
                var actual = context.LoadedAssemblies.FirstOrDefault(x => x.FullName.Equals(target.FullName));

                Assert.NotNull(actual);
                Assert.Equal(target.FullName, actual.FullName);
                Assert.Equal(string.Empty, actual.Location);
                Assert.Equal(target.CodeBase, target.CodeBase);
            }
        }
Beispiel #5
0
        public void LoadTargetWithReferences_InternalReferences_LoadBitsNoPdbSpecified()
        {
            using (var context = AppDomainContext.Create())
            {
                var prevNumAssemblies = context.LoadedAssemblies.Count();

                // Add the correct resolver path for the test dir.
                context.RemoteResolver.AddProbePath(Path.GetFullPath(InternalRefsAssemblyDir));
                var targetPath = Path.GetFullPath(InternalRefsAssemblyPath);
                var assembly   = Assembly.LoadFile(targetPath);
                var target     = AssemblyTarget.FromAssembly(assembly);

                var targets = context.LoadTargetWithReferences(LoadMethod.LoadBits, target);

                Assert.True(context.LoadedAssemblies.Count() > prevNumAssemblies);
                Assert.True(targets.Any(x => x.FullName.Contains(InternalRefsAssemblyName)));
                Assert.True(targets.Any(x => x.FullName.Contains(AssemblyAName)));
                Assert.True(targets.Any(x => x.FullName.Contains(AssemblyBName)));
            }
        }
Beispiel #6
0
 public void FromAssembly_NullArgument()
 {
     var target = AssemblyTarget.FromAssembly(null);
 }