2018-01-11 03:49:32 +08:00
|
|
|
|
namespace UglyToad.PdfPig.Tests.Graphics.Operations.SpecialGraphicsState
|
2017-11-27 06:19:42 +08:00
|
|
|
|
{
|
|
|
|
|
using System;
|
2018-01-11 03:49:32 +08:00
|
|
|
|
using PdfPig.Graphics;
|
|
|
|
|
using PdfPig.Graphics.Operations.SpecialGraphicsState;
|
2017-11-27 06:19:42 +08:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
public class PopTests
|
|
|
|
|
{
|
|
|
|
|
private readonly TestResourceStore resourceStore = new TestResourceStore();
|
|
|
|
|
private readonly TestOperationContext context = new TestOperationContext();
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void PopSymbolCorrect()
|
|
|
|
|
{
|
|
|
|
|
Assert.Equal("Q", Pop.Symbol);
|
|
|
|
|
Assert.Equal("Q", Pop.Value.Operator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CannotPopWithSingleFrame()
|
|
|
|
|
{
|
|
|
|
|
Action action = () => Pop.Value.Run(context, resourceStore);
|
|
|
|
|
|
|
|
|
|
Assert.Throws<InvalidOperationException>(action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CannotPopWithNoFrames()
|
|
|
|
|
{
|
|
|
|
|
context.StateStack.Pop();
|
|
|
|
|
|
|
|
|
|
Action action = () => Pop.Value.Run(context, resourceStore);
|
|
|
|
|
|
|
|
|
|
Assert.Throws<InvalidOperationException>(action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void PopsTopFrame()
|
|
|
|
|
{
|
|
|
|
|
context.StateStack.Push(new CurrentGraphicsState
|
|
|
|
|
{
|
|
|
|
|
LineWidth = 23
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Pop.Value.Run(context, resourceStore);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(1, context.StackSize);
|
|
|
|
|
Assert.Equal(1, context.GetCurrentState().LineWidth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|