public void Build_ShouldPlacePagesInRightOrder_ForOneProductOneSheet4Up() { var sourceFiles = new List <SourceFile> { new SourceFile { FileName = "test_file_name.pdf", Pages = GetFakeSourcePages(8) } }; var actual = _target.Build(sourceFiles); actual.Pages.Count.ShouldBe(2); actual.Pages.ShouldAllBe(p => p.ColumnsCount == 2); actual.Pages.ShouldAllBe(p => p.RowsCount == 2); var frontPage = actual.Pages.First(); var backPage = actual.Pages.Last(); frontPage.Tiles[0, 0].SourcePage.Number.ShouldBe(7); frontPage.Tiles[0, 1].SourcePage.Number.ShouldBe(3); frontPage.Tiles[1, 0].SourcePage.Number.ShouldBe(5); frontPage.Tiles[1, 1].SourcePage.Number.ShouldBe(1); backPage.Tiles[0, 0].SourcePage.Number.ShouldBe(6); backPage.Tiles[0, 1].SourcePage.Number.ShouldBe(2); backPage.Tiles[1, 0].SourcePage.Number.ShouldBe(8); backPage.Tiles[1, 1].SourcePage.Number.ShouldBe(4); }
public void Build_ShouldSetValuesFromLayout() { var sourceFiles = new List <SourceFile> { new SourceFile { FileName = "test_file_name.pdf", Pages = GetFakeSourcePages(2) } }; var layout = new Layout { Tiles = new List <Tile> { new Tile() }, SheetSize = new Size { Width = 300, Height = 320 } }; var target = new DuplexSmartStackerOutputFileBuilder(layout, new Imposition()); var actual = target.Build(sourceFiles); actual.SheetSize.ShouldBe(layout.SheetSize); }
public void Build_ShouldSetCorrectTileParameters() { // todo: move tile building to a separate testable class var layout = new Layout { Tiles = new List <Tile> { new Tile { RowIndex = 0, ColumnIndex = 0, MediaBox = new Box { Left = 0, Bottom = 100, Width = 100, Height = 100 }, CutBox = new Box { Left = 10, Bottom = 110, Width = 80, Height = 80 } }, new Tile { RowIndex = 0, ColumnIndex = 1, MediaBox = new Box { Left = 100, Bottom = 100, Width = 100, Height = 100 }, CutBox = new Box { Left = 110, Bottom = 110, Width = 80, Height = 80 } }, new Tile { RowIndex = 1, ColumnIndex = 0, MediaBox = new Box { Left = 0, Bottom = 0, Width = 100, Height = 100 }, CutBox = new Box { Left = 10, Bottom = 10, Width = 80, Height = 80 } }, new Tile { RowIndex = 1, ColumnIndex = 1, MediaBox = new Box { Left = 100, Bottom = 0, Width = 100, Height = 100 }, CutBox = new Box { Left = 110, Bottom = 10, Width = 80, Height = 80 } } } }; var imposition = new Imposition { MediaRotationAngle = 90.0f }; var target = new DuplexSmartStackerOutputFileBuilder(layout, imposition); var sourceFiles = new List <SourceFile> { new SourceFile { FileName = "test_file_name.pdf", Pages = GetFakeSourcePages(8) } }; var actual = target.Build(sourceFiles); void ValidateTiles(List <OutputTile> tilesToValidate, Tile layoutTile) { foreach (var outputTile in tilesToValidate) { outputTile.MediaBox.ShouldBe(layoutTile.MediaBox); outputTile.CutBox.ShouldBe(layoutTile.CutBox); outputTile.MediaRotationAngle.ShouldBe(imposition.MediaRotationAngle); } } ValidateTiles(actual.Pages.Select(p => p.Tiles[0, 0]).ToList(), layout.Tiles[0]); ValidateTiles(actual.Pages.Select(p => p.Tiles[0, 1]).ToList(), layout.Tiles[1]); ValidateTiles(actual.Pages.Select(p => p.Tiles[1, 0]).ToList(), layout.Tiles[2]); ValidateTiles(actual.Pages.Select(p => p.Tiles[1, 1]).ToList(), layout.Tiles[3]); }