using GAJ3T.MusicGen.RiffGrooveBuilder.Core.Articulations; using GAJ3T.MusicGen.RiffGrooveBuilder.Core.Composition; using GAJ3T.MusicGen.RiffGrooveBuilder.Generation.Instruments; using GAJ3T.MusicGen.RiffGrooveBuilder.Generation.Profiles; namespace GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests.Instruments; [CollectionDefinition("Instrument catalog working directory", DisableParallelization = true)] public sealed class InstrumentCatalogWorkingDirectoryCollection; [Collection("Instrument catalog working directory")] public sealed class InstrumentCatalogPipelineTests { [Fact] public void RealEmbeddedCatalogsJoinSevenTargetsWithFiveDocumentedCapabilitiesFromUnrelatedDirectory() { var previous = Environment.CurrentDirectory; try { Environment.CurrentDirectory = Environment.SystemDirectory; var instruments = InstrumentCatalog.LoadEmbedded(); var profiles = InstrumentProfileCatalog.LoadEmbedded(); Assert.Equal(new[] { "ample-abj", "ample-aglp", "ample-agm", "ample-agt", "ample-ame", "ample-amr", "toontrack-sd3" }, instruments.Instruments.Select(i => i.Id)); Assert.Equal(instruments.Instruments, profiles.Instruments.Select(i => i.Instrument)); Assert.Equal(4, instruments.ForRole(TrackRole.Lead).Count); Assert.Equal(2, instruments.ForRole(TrackRole.Bass).Count); Assert.Single(instruments.ForRole(TrackRole.Drums)); Assert.Equal(5, profiles.Profiles.Count); foreach (var entry in profiles.Instruments) { var selected = profiles.SelectInstrument(entry.Instrument.Role, entry.Instrument.Id); if (entry.Instrument.Id is "ample-abj" or "ample-aglp" or "ample-agm" or "ample-agt" or "ample-ame") { Assert.Equal("profile_available", entry.Availability); Assert.True(selected.Success); Assert.Same(Assert.Single(entry.Profiles), selected.Profile); Assert.Equal(MappingVerification.Documented, selected.Profile!.Evidence.Status); } else { Assert.Equal("mapping_unavailable", entry.Availability); Assert.Empty(entry.Profiles); Assert.False(selected.Success); Assert.Null(selected.Profile); Assert.Equal("mapping_unavailable", Assert.Single(selected.Diagnostics).Code); } } Assert.Equal("unknown_instrument", Assert.Single(profiles.SelectInstrument(TrackRole.Bass, "not-declared").Diagnostics).Code); var composition = CompositionPlanner.Plan("lead and bass and drums").Composition!; var result = ArticulationPlanner.Plan(composition, profiles.Profiles.Where(p => p.InstrumentId is "ample-ame" or "ample-abj")); Assert.False(result.Success); Assert.Null(result.Plan); Assert.Equal("Drums", Assert.Single(result.Diagnostics).Field); Assert.Equal("missing_or_duplicate_profile", result.Diagnostics[0].Code); } finally { Environment.CurrentDirectory = previous; } } }