using Launcher.Next.Application; using Xunit; namespace Launcher.Next.Tests; public sealed class LegacyNetworkSettingsParserTests { [Fact] public void FullLegacyPattern_PreservesSourcesAttributesAndMachineRestriction() { const string xml = "hcPlant 3D_2019Project files |Project.xml|All files (*.*)|*.*%PROJECTDIRECTORY%\\..\\_System\\Plant 3D_2019\\Applications\\download_list.xmlN:\\BIM\\save\\Apps\\Plant3D\\DriveAN:\\BIM\\save\\Apps\\Plant3D\\DriveQtargetloaderobjectfirstsecondb455ee6eaed79d76f084846a60ce3284P_Rec_AnnotOrthoLoader.dllBUILD-01"; var settings = new LegacyConfigurationAdapter().ParseSettings(xml); var pattern = Assert.Single(settings.Patterns); Assert.Equal(["N:\\BIM\\save\\Apps\\Plant3D\\DriveA", "N:\\BIM\\save\\Apps\\Plant3D\\DriveQ"], pattern.Sources); Assert.Equal(["first", "second"], pattern.Attributes); Assert.Equal("target", pattern.Target); var plugin = Assert.Single(pattern.Plugins); Assert.Equal("P_Rec_Annot", plugin.Catalog); Assert.True(plugin.IsAllowedOn("build-01")); Assert.False(plugin.IsAllowedOn("OTHER")); } [Fact] public void PluginWithoutMachineRestriction_IsAllowedEverywhere() { var plugin = new LegacyPluginDefinition("id", "", "catalog", "install", 0); Assert.True(plugin.IsAllowedOn(Environment.MachineName)); } [Fact] public void RealOwnerRosterShape_UsesAreaIdsInSourceOrderAndPreservesDuplicateEvidence() { const string roster = "1first second firstnot-selected"; var selection = new LegacyConfigurationAdapter().ParseDownloadList(roster); Assert.Equal(["first", " second ", "first"], selection.PluginIds); Assert.Equal(["first", " second "], selection.EffectivePluginIds); Assert.Equal("Area", selection.Entries![0].SourceShape); Assert.Equal(0, selection.Entries[2].FirstOccurrenceIndex); Assert.Equal("", selection.Entries[3].RawId); } [Fact] public void DownloadListErrors_AreSpecific() { var adapter = new LegacyConfigurationAdapter(); Assert.Equal("DOWNLOAD_LIST_ROOT_INVALID", Assert.Throws(() => adapter.ParseDownloadList("")).Message); Assert.Equal("DOWNLOAD_LIST_XML_MALFORMED", Assert.Throws(() => adapter.ParseDownloadList("")).Message); } }