43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace FurnitureExporter.Tests
|
|
{
|
|
public class CommandRegistrationTests
|
|
{
|
|
[Fact]
|
|
public void Fexport_DefaultsToSingleAssetExport()
|
|
{
|
|
var source = ReadCommandsSource();
|
|
|
|
Assert.Matches(CommandMethodPattern("FEXPORT", "ExportAssetDefault"), source);
|
|
Assert.Matches(CommandMethodPattern("FEXPORTASSET", "ExportSingleAsset"), source);
|
|
Assert.DoesNotMatch(CommandMethodPattern("FEXPORT", "ExportFurniture"), source);
|
|
}
|
|
|
|
[Fact]
|
|
public void LegacyProductBundleExport_UsesExplicitCompatibilityCommands()
|
|
{
|
|
var source = ReadCommandsSource();
|
|
|
|
Assert.Matches(CommandMethodPattern("FEXPORTPRODUCT", "ExportFurniture"), source);
|
|
Assert.Matches(CommandMethodPattern("FEXPORTBUNDLE", "ExportFurnitureBundle"), source);
|
|
}
|
|
|
|
private static string ReadCommandsSource()
|
|
{
|
|
var path = Path.GetFullPath(
|
|
Path.Combine(AppContext.BaseDirectory, @"..\..\..\..\Commands.cs"));
|
|
return File.ReadAllText(path);
|
|
}
|
|
|
|
private static Regex CommandMethodPattern(string commandName, string methodName)
|
|
{
|
|
return new Regex(
|
|
$@"\[CommandMethod\(""{Regex.Escape(commandName)}""\)\]\s+public\s+void\s+{Regex.Escape(methodName)}\s*\(",
|
|
RegexOptions.Multiline);
|
|
}
|
|
}
|
|
}
|