36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text.Json;
|
|
using AcDream.App.UI.Layout;
|
|
using DatReaderWriter;
|
|
using DatReaderWriter.Options;
|
|
|
|
namespace AcDream.App.Tests.UI.Layout;
|
|
|
|
/// <summary>One-off generator for the committed retail radar LayoutDesc fixture.</summary>
|
|
public sealed class RadarLayoutFixtureGenerator
|
|
{
|
|
[Fact(Skip = "manual: regenerates the committed radar fixture; needs the real dats (ACDREAM_DAT_DIR)")]
|
|
public void GenerateRadarFixture()
|
|
{
|
|
var datDir = Environment.GetEnvironmentVariable("ACDREAM_DAT_DIR")
|
|
?? Path.Combine(
|
|
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
|
|
"Documents",
|
|
"Asheron's Call");
|
|
using var dats = new DatCollection(datDir, DatAccessType.Read);
|
|
var info = LayoutImporter.ImportInfos(dats, RadarController.LayoutId);
|
|
Assert.NotNull(info);
|
|
|
|
var json = JsonSerializer.Serialize(info, new JsonSerializerOptions
|
|
{
|
|
IncludeFields = true,
|
|
WriteIndented = true,
|
|
});
|
|
File.WriteAllText(FixturePath(), json);
|
|
}
|
|
|
|
private static string FixturePath([CallerFilePath] string thisFile = "")
|
|
=> Path.Combine(Path.GetDirectoryName(thisFile)!, "fixtures", "radar_21000074.json");
|
|
}
|