public void Load_Culture_Mismatch() { string tempDir = Path.Combine(Path.GetTempPath(), "MonoTests.System.Reflection.AssemblyTest"); string 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 = "bug79712a"; aname.CultureInfo = new CultureInfo("nl-BE"); cdt.GenerateAssembly(aname, Path.Combine(tempDir, "bug79712a.dll")); aname = new AssemblyName(); aname.Name = "bug79712a"; aname.CultureInfo = CultureInfo.InvariantCulture; #if NET_2_0 Assert.IsTrue(cdt.AssertFileNotFoundException(aname), "#A1"); #else Assert.IsTrue(cdt.AssertFileLoadException(aname), "#A2"); #endif // PART B aname = new AssemblyName(); aname.Name = "bug79712b"; aname.CultureInfo = new CultureInfo("nl-BE"); cdt.GenerateAssembly(aname, Path.Combine(tempDir, "en-US/bug79712b.dll")); aname = new AssemblyName(); aname.Name = "bug79712b"; aname.CultureInfo = new CultureInfo("en-US"); #if NET_2_0 Assert.IsTrue(cdt.AssertFileNotFoundException(aname), "#B1"); #else Assert.IsTrue(cdt.AssertFileLoadException(aname), "#B2"); #endif } finally { AppDomain.Unload(ad); if (Directory.Exists(tempDir)) { Directory.Delete(tempDir, true); } } }
[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); } } }