AssertLoad() public method

public AssertLoad ( AssemblyName assemblyRef ) : bool
assemblyRef AssemblyName
return bool
コード例 #1
0
        [Test] // bug #79715
        public void Load_PartialVersion()
        {
            string tempDir = Path.Combine(Path.GetTempPath(),
                                          "MonoTests.System.Reflection.AssemblyTest");

            if (!Directory.Exists(tempDir))
            {
                Directory.CreateDirectory(tempDir);
            }

            AppDomain ad = CreateTestDomain(tempDir, true);

            try
            {
                CrossDomainTester cdt = CreateCrossDomainTester(ad);

                AssemblyName aname = new AssemblyName();
                aname.Name    = "bug79715";
                aname.Version = new Version(1, 2, 3, 4);
                cdt.GenerateAssembly(aname, Path.Combine(tempDir, "bug79715.dll"));

                aname         = new AssemblyName();
                aname.Name    = "bug79715";
                aname.Version = new Version(1, 2);
                Assert.IsTrue(cdt.AssertLoad(aname), "#A1");
                Assert.IsTrue(cdt.AssertLoad(aname.FullName), "#A2");

                aname         = new AssemblyName();
                aname.Name    = "bug79715";
                aname.Version = new Version(1, 2, 3);
                Assert.IsTrue(cdt.AssertLoad(aname), "#B1");
                Assert.IsTrue(cdt.AssertLoad(aname.FullName), "#B2");

                aname         = new AssemblyName();
                aname.Name    = "bug79715";
                aname.Version = new Version(1, 2, 3, 4);
                Assert.IsTrue(cdt.AssertLoad(aname), "#C1");
                Assert.IsTrue(cdt.AssertLoad(aname.FullName), "#C2");
            }
            finally
            {
                AppDomain.Unload(ad);
                if (Directory.Exists(tempDir))
                {
                    Directory.Delete(tempDir, true);
                }
            }
        }
コード例 #2
0
ファイル: AssemblyTest.cs プロジェクト: xiaopingguan/mono
        [Category("NotWorking")]          // patch for bug #79720 must be committed first
        public void Load_Culture()
        {
            string tempDir = Path.Combine(Path.GetTempPath(),
                                          "MonoTests.System.Reflection.AssemblyTest");
            string cultureTempDir = Path.Combine(tempDir, "nl-BE");

            if (!Directory.Exists(cultureTempDir))
            {
                Directory.CreateDirectory(cultureTempDir);
            }
            cultureTempDir = Path.Combine(tempDir, "en-US");
            if (!Directory.Exists(cultureTempDir))
            {
                Directory.CreateDirectory(cultureTempDir);
            }


            AppDomain ad = CreateTestDomain(tempDir, true);

            try {
                CrossDomainTester cdt = CreateCrossDomainTester(ad);

                // PART A

                AssemblyName aname = new AssemblyName();
                aname.Name = "culturea";
                cdt.GenerateAssembly(aname, Path.Combine(tempDir, "culturea.dll"));

                aname      = new AssemblyName();
                aname.Name = "culturea";
                Assert.IsTrue(cdt.AssertLoad(aname), "#A1");

                aname             = new AssemblyName();
                aname.Name        = "culturea";
                aname.CultureInfo = new CultureInfo("nl-BE");
                Assert.IsTrue(cdt.AssertFileNotFoundException(aname), "#A2");

                aname             = new AssemblyName();
                aname.Name        = "culturea";
                aname.CultureInfo = CultureInfo.InvariantCulture;
                Assert.IsTrue(cdt.AssertLoad(aname), "#A3");

                // PART B

                aname             = new AssemblyName();
                aname.Name        = "cultureb";
                aname.CultureInfo = new CultureInfo("nl-BE");
                cdt.GenerateAssembly(aname, Path.Combine(tempDir, "cultureb.dll"));

                aname             = new AssemblyName();
                aname.Name        = "cultureb";
                aname.CultureInfo = new CultureInfo("nl-BE");
                Assert.IsTrue(cdt.AssertFileNotFoundException(aname), "#B1");

                aname      = new AssemblyName();
                aname.Name = "cultureb";
                Assert.IsTrue(cdt.AssertLoad(aname), "#B2");

                aname             = new AssemblyName();
                aname.Name        = "cultureb";
                aname.CultureInfo = new CultureInfo("en-US");
                Assert.IsTrue(cdt.AssertFileNotFoundException(aname), "#B3");

                // PART C

                aname             = new AssemblyName();
                aname.Name        = "culturec";
                aname.CultureInfo = new CultureInfo("nl-BE");
                cdt.GenerateAssembly(aname, Path.Combine(tempDir, "nl-BE/culturec.dll"));

                aname             = new AssemblyName();
                aname.Name        = "culturec";
                aname.CultureInfo = new CultureInfo("nl-BE");
                Assert.IsTrue(cdt.AssertLoad(aname), "#C1");

                aname      = new AssemblyName();
                aname.Name = "culturec";
                Assert.IsTrue(cdt.AssertFileNotFoundException(aname), "#C2");

                aname             = new AssemblyName();
                aname.Name        = "culturec";
                aname.CultureInfo = CultureInfo.InvariantCulture;
                Assert.IsTrue(cdt.AssertFileNotFoundException(aname), "#C3");

                // PART D

                aname             = new AssemblyName();
                aname.Name        = "cultured";
                aname.CultureInfo = new CultureInfo("nl-BE");
                cdt.GenerateAssembly(aname, Path.Combine(tempDir, "en-US/cultured.dll"));

                aname             = new AssemblyName();
                aname.Name        = "cultured";
                aname.CultureInfo = new CultureInfo("nl-BE");
                Assert.IsTrue(cdt.AssertFileNotFoundException(aname), "#D1");

                aname      = new AssemblyName();
                aname.Name = "cultured";
                Assert.IsTrue(cdt.AssertFileNotFoundException(aname), "#D2");

                aname             = new AssemblyName();
                aname.Name        = "cultured";
                aname.CultureInfo = CultureInfo.InvariantCulture;
                Assert.IsTrue(cdt.AssertFileNotFoundException(aname), "#D3");
            } finally {
                AppDomain.Unload(ad);
                if (Directory.Exists(tempDir))
                {
                    Directory.Delete(tempDir, true);
                }
            }
        }