final receipt update
This commit is contained in:
@@ -56,8 +56,8 @@ public class InterpreterLoopTests
|
||||
var interpreter = new TemplateInterpreter(_profile);
|
||||
var commands = interpreter.Interpret(template, """{"Items": ["A", "B"]}""");
|
||||
|
||||
Assert.Contains(commands, c => c.Text == "0");
|
||||
Assert.Contains(commands, c => c.Text == "1");
|
||||
Assert.Contains(commands, c => c.Text == "0:A");
|
||||
Assert.Contains(commands, c => c.Text == "1:B");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -67,8 +67,8 @@ public class InterpreterLoopTests
|
||||
var interpreter = new TemplateInterpreter(_profile);
|
||||
var commands = interpreter.Interpret(template, """{"Items": ["A", "B"]}""");
|
||||
|
||||
Assert.Contains(commands, c => c.Text == "1");
|
||||
Assert.Contains(commands, c => c.Text == "2");
|
||||
Assert.Contains(commands, c => c.Text == "1. A");
|
||||
Assert.Contains(commands, c => c.Text == "2. B");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -78,9 +78,7 @@ public class InterpreterLoopTests
|
||||
var interpreter = new TemplateInterpreter(_profile);
|
||||
var commands = interpreter.Interpret(template, """{"Items": ["A", "B", "C"]}""");
|
||||
|
||||
var firstCmds = commands.Where(c => c.Text.Contains("First")).ToList();
|
||||
Assert.Single(firstCmds);
|
||||
Assert.Contains(commands, c => c.Text == "A");
|
||||
Assert.Contains(commands, c => c.Text == "First: A");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -90,8 +88,7 @@ public class InterpreterLoopTests
|
||||
var interpreter = new TemplateInterpreter(_profile);
|
||||
var commands = interpreter.Interpret(template, """{"Items": ["A", "B", "C"]}""");
|
||||
|
||||
Assert.Contains(commands, c => c.Text.Contains("Last"));
|
||||
Assert.Contains(commands, c => c.Text == "C");
|
||||
Assert.Contains(commands, c => c.Text == "Last: C");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -115,9 +112,8 @@ public class InterpreterLoopTests
|
||||
var interpreter = new TemplateInterpreter(_profile);
|
||||
var commands = interpreter.Interpret(template, """{"Title": "List", "Items": ["A", "B"]}""");
|
||||
|
||||
Assert.Contains(commands, c => c.Text == "List");
|
||||
Assert.Contains(commands, c => c.Text == "A");
|
||||
Assert.Contains(commands, c => c.Text == "B");
|
||||
Assert.Contains(commands, c => c.Text == "List: A");
|
||||
Assert.Contains(commands, c => c.Text == "List: B");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -102,4 +102,105 @@ public class InterpreterRowTests
|
||||
Assert.NotNull(rowCmd);
|
||||
Assert.Equal(30, rowCmd.Text.Length);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Interpret_Row_WithBoldStyle_SetsBold()
|
||||
{
|
||||
var template = Parse("@row bold\n|20|Name|10,right|Price\n@endrow");
|
||||
var interpreter = new TemplateInterpreter(_profile);
|
||||
var commands = interpreter.Interpret(template, "{}");
|
||||
|
||||
var rowCmd = commands.FirstOrDefault(c => c.Text.Contains("Name") && c.Text.Contains("Price"));
|
||||
Assert.NotNull(rowCmd);
|
||||
Assert.True(rowCmd.IsBold);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Interpret_Row_WithBigStyle_SetsBig()
|
||||
{
|
||||
var template = Parse("@row big\n|12|Name|6,right|Price\n@endrow");
|
||||
var interpreter = new TemplateInterpreter(_profile);
|
||||
var commands = interpreter.Interpret(template, "{}");
|
||||
|
||||
var rowCmd = commands.FirstOrDefault(c => c.Text.Contains("Name") && c.Text.Contains("Price"));
|
||||
Assert.NotNull(rowCmd);
|
||||
Assert.True(rowCmd.IsBig);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Interpret_Row_WithTallStyle_SetsTall()
|
||||
{
|
||||
var template = Parse("@row tall\n|20|Name|10,right|Price\n@endrow");
|
||||
var interpreter = new TemplateInterpreter(_profile);
|
||||
var commands = interpreter.Interpret(template, "{}");
|
||||
|
||||
var rowCmd = commands.FirstOrDefault(c => c.Text.Contains("Name") && c.Text.Contains("Price"));
|
||||
Assert.NotNull(rowCmd);
|
||||
Assert.True(rowCmd.IsTall);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Interpret_Row_WithMultipleStyles_AppliesAll()
|
||||
{
|
||||
var template = Parse("@row bold, big\n|12|Name|6,right|Price\n@endrow");
|
||||
var interpreter = new TemplateInterpreter(_profile);
|
||||
var commands = interpreter.Interpret(template, "{}");
|
||||
|
||||
var rowCmd = commands.FirstOrDefault(c => c.Text.Contains("Name") && c.Text.Contains("Price"));
|
||||
Assert.NotNull(rowCmd);
|
||||
Assert.True(rowCmd.IsBold);
|
||||
Assert.True(rowCmd.IsBig);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Interpret_Row_WithRedStyle_OnSupportedPrinter_SetsRed()
|
||||
{
|
||||
var redProfile = new PrinterProfile("test", "Test Printer", 48, 24, SupportsRed: true);
|
||||
var template = Parse("@row red\n|20|Warning|10,right|!\n@endrow");
|
||||
var interpreter = new TemplateInterpreter(redProfile);
|
||||
var commands = interpreter.Interpret(template, "{}");
|
||||
|
||||
var rowCmd = commands.FirstOrDefault(c => c.Text.Contains("Warning"));
|
||||
Assert.NotNull(rowCmd);
|
||||
Assert.True(rowCmd.IsRed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Interpret_Row_WithRedStyle_OnUnsupportedPrinter_DoesNotSetRed()
|
||||
{
|
||||
var template = Parse("@row red\n|20|Warning|10,right|!\n@endrow");
|
||||
var interpreter = new TemplateInterpreter(_profile); // _profile has supportsRed: false
|
||||
var commands = interpreter.Interpret(template, "{}");
|
||||
|
||||
var rowCmd = commands.FirstOrDefault(c => c.Text.Contains("Warning"));
|
||||
Assert.NotNull(rowCmd);
|
||||
Assert.False(rowCmd.IsRed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Interpret_Row_WithoutStyles_NoStylesApplied()
|
||||
{
|
||||
var template = Parse("@row\n|20|Name|10,right|Price\n@endrow");
|
||||
var interpreter = new TemplateInterpreter(_profile);
|
||||
var commands = interpreter.Interpret(template, "{}");
|
||||
|
||||
var rowCmd = commands.FirstOrDefault(c => c.Text.Contains("Name") && c.Text.Contains("Price"));
|
||||
Assert.NotNull(rowCmd);
|
||||
Assert.False(rowCmd.IsBold);
|
||||
Assert.False(rowCmd.IsBig);
|
||||
Assert.False(rowCmd.IsTall);
|
||||
Assert.False(rowCmd.IsRed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Interpret_Row_WithSpacingStyle_SetsLineSpacing()
|
||||
{
|
||||
var template = Parse("@row spacing:50\n|20|Name|10,right|Price\n@endrow");
|
||||
var interpreter = new TemplateInterpreter(_profile);
|
||||
var commands = interpreter.Interpret(template, "{}");
|
||||
|
||||
var rowCmd = commands.FirstOrDefault(c => c.Text.Contains("Name") && c.Text.Contains("Price"));
|
||||
Assert.NotNull(rowCmd);
|
||||
Assert.Equal(50, rowCmd.SetLineSpacing);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user