public void CustomAlternatingRowColors([Random(10, 20, 1)] int itemCount, [Random(3, 7, 1)] int differentColors)
        {
            IList <IPrintContent> retrievedContent = new List <IPrintContent>();
            var pp = new PrintProcessorWithPrintOnAttribute(retrievedContent)
            {
                ItemCount             = itemCount,
                IsAlternatingRowColor = true
            };

            var colorList = new List <SolidColorBrush>();
            var r         = new Random();

            for (int i = 0; i < differentColors; i++)
            {
                colorList.Add(new SolidColorBrush(Color.FromRgb((byte)r.Next(0, 255), (byte)r.Next(0, 255), (byte)r.Next(0, 255))));
            }
            pp.AlternatingRowColors = colorList;

            var printDialog = new Mock <IPrintDialog>();

            printDialog.Setup(i => i.ShowDialog()).Returns(true);

            pp.PrintDialog = printDialog.Object;
            pp.PrintDocument();

            for (int i = 0; i < itemCount; i++)
            {
                Assert.That(retrievedContent[i].Content.GetValue(Panel.BackgroundProperty), Is.EqualTo(colorList[i % differentColors]));
            }
        }
        public void CheckPrintDimensions_HasPrintDimensionsSet()
        {
            var print = new PrintProcessorWithPrintOnAttribute();

            var printDialog = new Mock<IPrintDialog>();
            printDialog.Setup(i => i.ShowDialog()).Returns(true);

            print.PrintDialog = printDialog.Object;
            print.PrintDocument();

            Assert.That(print.PrintDefinition.IsDefined(PrintAppendixes.Footer));
        }
        public void CheckPrintDimensions_HasPrintDimensionsSet()
        {
            var print = new PrintProcessorWithPrintOnAttribute();

            var printDialog = new Mock <IPrintDialog>();

            printDialog.Setup(i => i.ShowDialog()).Returns(true);

            print.PrintDialog = printDialog.Object;
            print.PrintDocument();

            Assert.That(print.PrintDefinition.IsDefined(PrintAppendixes.Footer));
        }
Exemplo n.º 4
0
        public void IsAlternatingRowColor_True_Coloring()
        {
            IList <IPrintContent> retrievedContent = new List <IPrintContent>();
            var pp = new PrintProcessorWithPrintOnAttribute(retrievedContent);

            pp.ItemCount             = 3;
            pp.IsAlternatingRowColor = true;

            var printDialog = new Mock <IPrintDialog>();

            printDialog.Setup(i => i.ShowDialog()).Returns(true);

            pp.PrintDialog = printDialog.Object;
            pp.PrintDocument();

            Assert.That(retrievedContent[0].Content.GetValue(Panel.BackgroundProperty), Is.EqualTo(pp.AlternatingRowColors[0]));
            Assert.That(retrievedContent[1].Content.GetValue(Panel.BackgroundProperty), Is.EqualTo(pp.AlternatingRowColors[1 % 2]));
            Assert.That(retrievedContent[2].Content.GetValue(Panel.BackgroundProperty), Is.EqualTo(pp.AlternatingRowColors[2 % 2]));
        }
        public void CustomAlternatingRowColors([Random(10, 20, 1)] int itemCount, [Random(3, 7, 1)] int differentColors)
        {
            IList<IPrintContent> retrievedContent = new List<IPrintContent>();
            var pp = new PrintProcessorWithPrintOnAttribute(retrievedContent);
            pp.ItemCount = itemCount;
            pp.IsAlternatingRowColor = true;

            var colorList = new List<SolidColorBrush>();
            var r = new Random();
            for (int i = 0; i < differentColors; i++)
            {
                colorList.Add(new SolidColorBrush(Color.FromRgb((byte)r.Next(0, 255), (byte)r.Next(0, 255), (byte)r.Next(0, 255))));
            }
            pp.AlternatingRowColors = colorList;

            var printDialog = new Mock<IPrintDialog>();
            printDialog.Setup(i => i.ShowDialog()).Returns(true);

            pp.PrintDialog = printDialog.Object;
            pp.PrintDocument();

            for (int i = 0; i < itemCount; i++)
            {
                Assert.That(retrievedContent[i].Content.GetValue(Panel.BackgroundProperty), Is.EqualTo(colorList[i % differentColors]));
            }
        }
        public void IsAlternatingRowColor_True_Coloring()
        {
            IList<IPrintContent> retrievedContent = new List<IPrintContent>();
            var pp = new PrintProcessorWithPrintOnAttribute(retrievedContent);
            pp.ItemCount = 3;
            pp.IsAlternatingRowColor = true;

            var printDialog = new Mock<IPrintDialog>();
            printDialog.Setup(i => i.ShowDialog()).Returns(true);

            pp.PrintDialog = printDialog.Object;
            pp.PrintDocument();

            Assert.That(retrievedContent[0].Content.GetValue(Panel.BackgroundProperty), Is.EqualTo(pp.AlternatingRowColors[0]));
            Assert.That(retrievedContent[1].Content.GetValue(Panel.BackgroundProperty), Is.EqualTo(pp.AlternatingRowColors[1 % 2]));
            Assert.That(retrievedContent[2].Content.GetValue(Panel.BackgroundProperty), Is.EqualTo(pp.AlternatingRowColors[2 % 2]));
        }