コード例 #1
0
 public void FromPath_NullCodebase()
 {
     Assert.Throws(typeof(ArgumentNullException), () =>
     {
         var target = AssemblyTarget.FromPath(null);
     });
 }
コード例 #2
0
 public void FromAssembly_NullArgument()
 {
     Assert.Throws(typeof(ArgumentNullException), () =>
     {
         var target = AssemblyTarget.FromAssembly(null);
     });
 }
コード例 #3
0
 public void FromPath_NonExistingCodeBase()
 {
     Assert.Throws(typeof(FileNotFoundException), () =>
     {
         var location = Path.GetFullPath(string.Format("{0}/{1}", Guid.NewGuid().ToString(), Path.GetRandomFileName()));
         var target   = AssemblyTarget.FromPath(new Uri(location));
     });
 }
コード例 #4
0
        public void FromPath_CurrentAssembly()
        {
            var assembly = Assembly.GetExecutingAssembly();
            var target   = AssemblyTarget.FromPath(new Uri(assembly.CodeBase), assembly.Location, assembly.FullName);

            Assert.NotNull(target);
            Assert.Equal(assembly.CodeBase, target.CodeBase.ToString());
            Assert.Equal(assembly.Location, target.Location);
            Assert.Equal(assembly.FullName, target.FullName);
        }
コード例 #5
0
        public void FromAssembly_CurrentAssembly()
        {
            var assembly = Assembly.GetExecutingAssembly();
            var target   = AssemblyTarget.FromAssembly(assembly);

            Assert.IsNotNull(target);
            Assert.AreEqual(assembly.CodeBase, target.CodeBase.ToString());
            Assert.AreEqual(assembly.Location, target.Location);
            Assert.AreEqual(assembly.FullName, target.FullName);
        }
コード例 #6
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());
        }
コード例 #7
0
        public static void Main(string[] args)
        {
            TypeTarget t1 = new TypeTarget(typeof(GenericTest <,>));

            AssemblyTarget a1 = new AssemblyTarget(typeof(TypeTarget).Assembly);

            var jsonSerializerSettings = new JsonSerializerSettings()
            {
                Formatting        = Formatting.Indented,
                NullValueHandling = NullValueHandling.Ignore
            };

            Console.WriteLine(JsonConvert.SerializeObject(a1, jsonSerializerSettings));
            Console.ReadKey();
        }
コード例 #8
0
        public void if_you_have_the_assembly_name_and_file()
        {
            var registration = MockRepository.GenerateMock <IAssemblyRegistration>();

            var theAssembly = GetType().Assembly;

            var target = new AssemblyTarget {
                AssemblyName = theAssembly.GetName().Name,
                FilePath     = theAssembly.Location
            };

            target.Load(registration);

            registration.AssertWasNotCalled(x => x.Use(theAssembly));
            registration.AssertWasCalled(x => x.LoadFromFile(target.FilePath, target.AssemblyName));
        }
コード例 #9
0
        public void if_you_have_the_assembly_name_and_file()
        {
            var registration = MockRepository.GenerateMock<IAssemblyRegistration>();

            var theAssembly = GetType().Assembly;

            var target = new AssemblyTarget{
                AssemblyName = theAssembly.GetName().Name,
                FilePath = theAssembly.Location
            };

            target.Load(registration);

            registration.AssertWasNotCalled(x => x.Use(theAssembly));
            registration.AssertWasCalled(x => x.LoadFromFile(target.FilePath, target.AssemblyName));
        }
コード例 #10
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);
            }
        }
コード例 #11
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)));
            }
        }
コード例 #12
0
ファイル: Settings.cs プロジェクト: zippo227/xamarin-macios
        public override string ToString()
        {
            var builder = new StringBuilder();

            builder.AppendFormat("  Profile:\n");
            builder.Append(Profile);
            builder.AppendFormat("  Show help:         {0}\n", ShowHelp);
            builder.AppendFormat("  Verbose:           {0}\n", Verbose);
            builder.AppendFormat("  Time:              {0}\n", Time);
            builder.AppendFormat("  Clean mode:        {0}\n", CleanMode);
            builder.AppendFormat("  Omit #line:        {0}\n", OmitLineDirective);
            builder.AppendFormat("  Skip .mdb rebase:  {0}\n", SkipMdbRebase);
            builder.AppendFormat("  Keep preprocessed: {0}\n", KeepPreprocessedFiles);
            builder.AppendFormat("  Skip compilation:  {0}\n", SkipCompilation);
            builder.AppendFormat("  In-place preproc:  {0}\n", PreprocessInPlace);
            builder.AppendFormat("  Output to stdout:  {0}\n", PreprocessToStdout);
            builder.AppendFormat("  Assembly out file: {0}\n", AssemblyOutFile);
            builder.AppendFormat("  Assembly target:   {0}\n", AssemblyTarget.ToString().ToLower());
            builder.AppendFormat("  Explicit -out:     {0}\n", HaveExplicitOutOption);
            builder.AppendFormat("  Compiler paths:    {0}\n", String.Join(" ", CompilerPaths));
            return(builder.ToString());
        }
コード例 #13
0
 public void FromPath_NonExistingCodeBase()
 {
     var location = Path.GetFullPath(Guid.NewGuid().ToString() + "/" + Path.GetRandomFileName());
     var target   = AssemblyTarget.FromPath(new Uri(location));
 }
コード例 #14
0
 public void FromPath_NonExistingLocationExistingCodeBase()
 {
     var assembly = Assembly.GetExecutingAssembly();
     var location = Guid.NewGuid().ToString() + "/" + Path.GetRandomFileName();
     var target   = AssemblyTarget.FromPath(new Uri(assembly.CodeBase), location);
 }
コード例 #15
0
 public void FromPath_NullCodebase()
 {
     var target = AssemblyTarget.FromPath(null);
 }
コード例 #16
0
 public void FromAssembly_NullArgument()
 {
     var target = AssemblyTarget.FromAssembly(null);
 }