public void RecalculateHeightValueWhen([Random(10, 100, 1)] int initialHeight) { PrintDimension pd = new PrintDimension { InternalPrintDefinition = new PrintDefinition() }; pd.InternalPrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.All)); Mock <IPrintProcessor> printProcessor = new Mock <IPrintProcessor>(); printProcessor.Setup(i => i.GetSummary()).Returns(() => new Grid() { Height = initialHeight }); pd.PrintProcessor = printProcessor.Object; Assert.That(pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Is.EqualTo(initialHeight)); pd.SetHeightValue(PrintAppendixes.Summary, 5); pd.RecalculateHeightValueWhen(() => false, PrintAppendixes.Summary); Assert.That(pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Is.EqualTo(5)); pd.RecalculateHeightValueWhen(() => true, PrintAppendixes.Summary); Assert.That(pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Is.EqualTo(initialHeight)); Assert.That(() => pd.RecalculateHeightValueWhen(null, PrintAppendixes.Summary), Throws.ArgumentNullException); }
public void GetHeightFor() { Mock <IPrintProcessor> mock = new Mock <IPrintProcessor>(); mock.Setup(i => i.GetHeader()).Returns(new Grid { Height = 1 }); mock.Setup(i => i.GetFooter()).Returns(new Grid { Height = 2 }); mock.Setup(i => i.GetHeaderDescription()).Returns(new Grid { Height = 3 }); PrintDimension pd = new PrintDimension { PrintProcessor = mock.Object, InternalPrintDefinition = new PrintDefinition() }; pd.InternalPrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.Header | PrintAppendixes.Footer | PrintAppendixes.Summary)); Assert.That(pd.GetHeightFor(PrintAppendixes.Header, 1, false), Is.EqualTo(1)); Assert.That(pd.GetHeightFor(PrintAppendixes.Footer, 1, false), Is.EqualTo(2)); Assert.That(pd.GetHeightFor(PrintAppendixes.HeaderDescription, 1, false), Is.EqualTo(0)); Assert.That(() => pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Throws.ArgumentNullException); pd.InternalPrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.HeaderDescription)); Assert.That(pd.GetHeightFor(PrintAppendixes.HeaderDescription, 1, false), Is.EqualTo(3)); }
public void SetHeightValue() { PrintDimension pd = new PrintDimension(); pd.InternalPrintDefinition = new PrintDefinition(); pd.InternalPrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.All)); pd.SetHeightValue(PrintAppendixes.Summary, 5); Assert.That(pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Is.EqualTo(5)); pd.SetHeightValue(PrintAppendixes.Summary, 6); Assert.That(pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Is.EqualTo(6)); }
public void SetHeightValue() { PrintDimension pd = new PrintDimension { InternalPrintDefinition = new PrintDefinition() }; pd.InternalPrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.All)); pd.SetHeightValue(PrintAppendixes.Summary, 5); Assert.That(pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Is.EqualTo(5)); pd.SetHeightValue(PrintAppendixes.Summary, 6); Assert.That(pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Is.EqualTo(6)); Assert.That(() => pd.SetHeightValue(PrintAppendixes.Summary, -1), Throws.TypeOf <ArgumentOutOfRangeException>()); }
public void GetHeightFor() { Mock<IPrintProcessor> mock = new Mock<IPrintProcessor>(); mock.Setup(i => i.GetHeader()).Returns(new Grid { Height = 1 }); mock.Setup(i => i.GetFooter()).Returns(new Grid { Height = 2 }); mock.Setup(i => i.GetHeaderDescription()).Returns(new Grid { Height = 3 }); PrintDimension pd = new PrintDimension(); pd.PrintProcessor = mock.Object; pd.InternalPrintDefinition = new PrintDefinition(); pd.InternalPrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.Header | PrintAppendixes.Footer | PrintAppendixes.Summary)); Assert.That(pd.GetHeightFor(PrintAppendixes.Header, 1, false), Is.EqualTo(1)); Assert.That(pd.GetHeightFor(PrintAppendixes.Footer, 1, false), Is.EqualTo(2)); Assert.That(pd.GetHeightFor(PrintAppendixes.HeaderDescription, 1, false), Is.EqualTo(0)); Assert.That(() => pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Throws.ArgumentNullException); pd.InternalPrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.HeaderDescription)); Assert.That(pd.GetHeightFor(PrintAppendixes.HeaderDescription, 1, false), Is.EqualTo(3)); }
public void RecalculateHeightValueWhen([Random(10, 100, 1)] int initialHeight) { PrintDimension pd = new PrintDimension(); pd.InternalPrintDefinition = new PrintDefinition(); pd.InternalPrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.All)); Mock<IPrintProcessor> printProcessor = new Mock<IPrintProcessor>(); printProcessor.Setup(i => i.GetSummary()).Returns(() => new Grid() { Height = initialHeight }); pd.PrintProcessor = printProcessor.Object; Assert.That(pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Is.EqualTo(initialHeight)); pd.SetHeightValue(PrintAppendixes.Summary, 5); pd.RecalculateHeightValueWhen(() => false, PrintAppendixes.Summary); Assert.That(pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Is.EqualTo(5)); pd.RecalculateHeightValueWhen(() => true, PrintAppendixes.Summary); Assert.That(pd.GetHeightFor(PrintAppendixes.Summary, 1, false), Is.EqualTo(initialHeight)); }