|
| 1 | +using Xunit; |
| 2 | + |
| 3 | +namespace OrchardCoreContrib.PoExtractor.Tests; |
| 4 | + |
| 5 | +public class ProgramTests |
| 6 | +{ |
| 7 | + [Fact] |
| 8 | + public void Main_NoTemplateOption_UsesBothRazorAndLiquid() |
| 9 | + { |
| 10 | + // Arrange |
| 11 | + var root = Path.Combine(Path.GetTempPath(), "PoExtractorTests", Guid.NewGuid().ToString("N")); |
| 12 | + var input = Path.Combine(root, "input"); |
| 13 | + var output = Path.Combine(root, "output"); |
| 14 | + var project = Path.Combine(input, "TestModule"); |
| 15 | + |
| 16 | + Directory.CreateDirectory(project); |
| 17 | + Directory.CreateDirectory(output); |
| 18 | + |
| 19 | + File.WriteAllText(Path.Combine(project, "TestModule.csproj"), """ |
| 20 | +<Project Sdk="Microsoft.NET.Sdk"> |
| 21 | + <PropertyGroup> |
| 22 | + <TargetFramework>net10.0</TargetFramework> |
| 23 | + </PropertyGroup> |
| 24 | +</Project> |
| 25 | +"""); |
| 26 | + |
| 27 | + File.WriteAllText(Path.Combine(project, "Index.cshtml"), """ |
| 28 | +@T["Hello from Razor"] |
| 29 | +"""); |
| 30 | + |
| 31 | + File.WriteAllText(Path.Combine(project, "index.liquid"), """ |
| 32 | +{{ "Hello from Liquid" | t }} |
| 33 | +"""); |
| 34 | + |
| 35 | + var potFileName = "all.pot"; |
| 36 | + |
| 37 | + try |
| 38 | + { |
| 39 | + // Act |
| 40 | + Program.Main( |
| 41 | + [ |
| 42 | + input, |
| 43 | + output, |
| 44 | + "--single", potFileName |
| 45 | + ]); |
| 46 | + |
| 47 | + // Assert |
| 48 | + var potPath = Path.Combine(output, potFileName); |
| 49 | + Assert.True(File.Exists(potPath)); |
| 50 | + |
| 51 | + var pot = File.ReadAllText(potPath); |
| 52 | + Assert.Contains("Hello from Razor", pot); |
| 53 | + Assert.Contains("Hello from Liquid", pot); |
| 54 | + } |
| 55 | + finally |
| 56 | + { |
| 57 | + if (Directory.Exists(root)) |
| 58 | + { |
| 59 | + Directory.Delete(root, recursive: true); |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | +} |
0 commit comments