final receipt update
This commit is contained in:
@@ -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