|
11 | 11 | using Microsoft.Playwright; |
12 | 12 | using Xunit.Abstractions; |
13 | 13 | using Xunit; |
| 14 | +using System.Xml.Linq; |
14 | 15 |
|
15 | 16 | #nullable enable |
16 | 17 |
|
@@ -38,4 +39,44 @@ public async Task LoadSatelliteAssembly() |
38 | 39 | m => Assert.Equal("es-ES with satellite: hola", m) |
39 | 40 | ); |
40 | 41 | } |
| 42 | + |
| 43 | + [Fact] |
| 44 | + public async Task LoadSatelliteAssemblyFromReference() |
| 45 | + { |
| 46 | + CopyTestAsset("WasmBasicTestApp", "SatelliteLoadingTestsFromReference", "App"); |
| 47 | + |
| 48 | + // Replace ProjectReference with Reference |
| 49 | + var appCsprojPath = Path.Combine(_projectDir!, "WasmBasicTestApp.csproj"); |
| 50 | + var appCsproj = XDocument.Load(appCsprojPath); |
| 51 | + |
| 52 | + var projectReference = appCsproj.Descendants("ProjectReference").Where(pr => pr.Attribute("Include")?.Value?.Contains("ResourceLibrary") ?? false).Single(); |
| 53 | + var itemGroup = projectReference.Parent!; |
| 54 | + projectReference.Remove(); |
| 55 | + |
| 56 | + var reference = new XElement("Reference"); |
| 57 | + reference.SetAttributeValue("Include", "..\\ResourceLibrary\\bin\\Release\\net9.0\\ResourceLibrary.dll"); |
| 58 | + itemGroup.Add(reference); |
| 59 | + |
| 60 | + appCsproj.Save(appCsprojPath); |
| 61 | + |
| 62 | + // Build the library |
| 63 | + var libraryCsprojPath = Path.GetFullPath(Path.Combine(_projectDir!, "..", "ResourceLibrary")); |
| 64 | + new DotNetCommand(s_buildEnv, _testOutput) |
| 65 | + .WithWorkingDirectory(libraryCsprojPath) |
| 66 | + .WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir) |
| 67 | + .ExecuteWithCapturedOutput("build -c Release") |
| 68 | + .EnsureSuccessful(); |
| 69 | + |
| 70 | + // Publish the app and assert |
| 71 | + PublishProject("Release"); |
| 72 | + |
| 73 | + var result = await RunSdkStyleAppForPublish(new(Configuration: "Release", TestScenario: "SatelliteAssembliesTest")); |
| 74 | + Assert.Collection( |
| 75 | + result.TestOutput, |
| 76 | + m => Assert.Equal("default: hello", m), |
| 77 | + m => Assert.Equal("es-ES without satellite: hello", m), |
| 78 | + m => Assert.Equal("default: hello", m), |
| 79 | + m => Assert.Equal("es-ES with satellite: hola", m) |
| 80 | + ); |
| 81 | + } |
41 | 82 | } |
0 commit comments