AetherDb economy: pin Run's report and author dry-run branches on the shipped catalog
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
da067a34a2
commit
3c3ecd40da
1 changed files with 40 additions and 0 deletions
|
|
@ -270,6 +270,46 @@ public sealed class EconomyCommandTests
|
|||
Assert.Contains("economy report | author", output.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReportOnTheShippedCatalogGoesToTheGivenWriterAndNeverToConsole()
|
||||
{
|
||||
using var db = AetherDb.Open();
|
||||
var expected = new StringWriter();
|
||||
var expectedCode = EconomyCommand.Report(db.Cache, expected);
|
||||
var console = new StringWriter();
|
||||
var previous = Console.Out;
|
||||
Console.SetOut(console);
|
||||
var output = new StringWriter();
|
||||
int code;
|
||||
try { code = EconomyCommand.Run(new[] { "report" }, output); }
|
||||
finally { Console.SetOut(previous); }
|
||||
Assert.Equal(expectedCode, code);
|
||||
Assert.NotEmpty(expected.ToString());
|
||||
Assert.Equal(expected.ToString(), output.ToString());
|
||||
Assert.Empty(console.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnAuthorDryRunReadsTheShippedCatalogAndLeavesItByteIdentical()
|
||||
{
|
||||
var path = Path.Combine(AetherDb.FindRoot(), "GameData", "Aetheria.cc");
|
||||
var before = File.ReadAllBytes(path);
|
||||
var expected = new StringWriter();
|
||||
var expectedCode = EconomyCommand.Author(path, new EconomyBatch[] { new Munitions() }, false, expected);
|
||||
var console = new StringWriter();
|
||||
var previous = Console.Out;
|
||||
Console.SetOut(console);
|
||||
var output = new StringWriter();
|
||||
int code;
|
||||
try { code = EconomyCommand.Run(new[] { "author", "Munitions" }, output); }
|
||||
finally { Console.SetOut(previous); }
|
||||
Assert.Equal(expectedCode, code);
|
||||
Assert.NotEmpty(expected.ToString());
|
||||
Assert.Equal(expected.ToString(), output.ToString());
|
||||
Assert.Empty(console.ToString());
|
||||
Assert.Equal(before, File.ReadAllBytes(path));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnUnknownBatchNameIsRefusedWithoutEchoingIt()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue