2018-01-11 03:49:32 +08:00
|
|
|
|
namespace UglyToad.PdfPig.Tests.Graphics.Operations.SpecialGraphicsState
|
2017-11-27 06:19:42 +08:00
|
|
|
|
{
|
2018-01-11 03:49:32 +08:00
|
|
|
|
using PdfPig.Graphics;
|
|
|
|
|
using PdfPig.Graphics.Operations.SpecialGraphicsState;
|
2017-11-27 06:19:42 +08:00
|
|
|
|
|
|
|
|
|
public class PopTests
|
|
|
|
|
{
|
|
|
|
|
private readonly TestOperationContext context = new TestOperationContext();
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void PopSymbolCorrect()
|
|
|
|
|
{
|
|
|
|
|
Assert.Equal("Q", Pop.Symbol);
|
|
|
|
|
Assert.Equal("Q", Pop.Value.Operator);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-19 19:00:43 +08:00
|
|
|
|
[Fact(Skip = "The stack size check has been moved out of the Pop Operation, and is now in BaseStreamProcessor.PopState().")]
|
2017-11-27 06:19:42 +08:00
|
|
|
|
public void CannotPopWithSingleFrame()
|
|
|
|
|
{
|
2019-01-04 06:20:53 +08:00
|
|
|
|
Action action = () => Pop.Value.Run(context);
|
2017-11-27 06:19:42 +08:00
|
|
|
|
|
|
|
|
|
Assert.Throws<InvalidOperationException>(action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CannotPopWithNoFrames()
|
|
|
|
|
{
|
|
|
|
|
context.StateStack.Pop();
|
|
|
|
|
|
2019-01-04 06:20:53 +08:00
|
|
|
|
Action action = () => Pop.Value.Run(context);
|
2017-11-27 06:19:42 +08:00
|
|
|
|
|
|
|
|
|
Assert.Throws<InvalidOperationException>(action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void PopsTopFrame()
|
|
|
|
|
{
|
|
|
|
|
context.StateStack.Push(new CurrentGraphicsState
|
|
|
|
|
{
|
|
|
|
|
LineWidth = 23
|
|
|
|
|
});
|
|
|
|
|
|
2019-01-04 06:20:53 +08:00
|
|
|
|
Pop.Value.Run(context);
|
2017-11-27 06:19:42 +08:00
|
|
|
|
|
|
|
|
|
Assert.Equal(1, context.StackSize);
|
|
|
|
|
Assert.Equal(1, context.GetCurrentState().LineWidth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|