Cubase-MCP-GAJ3T.MusicGen.R.../tests/GAJ3T.MusicGen.RiffGrooveBu.../Instruments/CatalogFixtures.cs

30 lines
1.2 KiB
C#

using System.Text;
using GAJ3T.MusicGen.RiffGrooveBuilder.Generation.Instruments;
using GAJ3T.MusicGen.RiffGrooveBuilder.Generation.Profiles;
namespace GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests.Instruments;
internal static class CatalogFixtures
{
internal static string Read(string name)
{
using var stream = typeof(CatalogFixtures).Assembly.GetManifestResourceStream(
"GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests.Instruments.Fixtures." + name)
?? throw new InvalidDataException("Missing test-only fixture.");
using var reader = new StreamReader(stream);
return reader.ReadToEnd();
}
internal static InstrumentCatalog Instruments(string? json = null)
{
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(json ?? Read("instruments.json")));
return InstrumentCatalog.Load(stream);
}
internal static InstrumentProfileCatalog Profiles(string? json = null, InstrumentCatalog? instruments = null)
{
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(json ?? Read("profiles.json")));
return InstrumentProfileCatalog.Load(stream, instruments ?? Instruments());
}
}