public void PrintDocument_NoPrintProcessor_DoesNotPrint()
        {
            var ppcoll = new PrintProcessorCollection(Enumerable.Empty <Printing.PrintProcessor.PrintProcessor>());

            Assert.That(ppcoll.PrintDocument(), Is.False);
            Assert.That(ppcoll.PrintDocument(string.Empty), Is.False);
        }
Example #2
0
        public void FileName_Null_IsStringEmpty()
        {
            var ppcoll = new PrintProcessorCollection(Enumerable.Empty <Printing.PrintProcessor.PrintProcessor>());

            ppcoll.FileName = null;
            Assert.That(ppcoll.FileName, Is.Empty);
        }
        public FixedDocument CreateFixedDocument(PrintProcessorCollection collection)
        {
            FixedDocument = new FixedDocument();

            if (collection != null)
            {
                foreach (var pp in collection)
                {
                    var currentPage = FixedDocument.Pages.Count;
                    _printProcessor   = pp;
                    CurrentPageNumber = 1;
                    _printProcessor   = pp;
                    IList <IPrintContent> itemCollection = _printProcessor.ItemCollection().ToList();

                    AddItems(itemCollection);
                    if (collection.IndividualPageNumbers)
                    {
                        AddPageNumbers(currentPage);
                    }
                }

                if (!collection.IndividualPageNumbers)
                {
                    AddPageNumbers();
                }
            }
            return(FixedDocument);
        }
        public void PreviewDocument()
        {
            var printProcessor = new PrintProcessorCollection(Enumerable.Empty <Printing.PrintProcessor.PrintProcessor>());
            var windowProvider = new Mock <IWindowProvider>();

            printProcessor.PreviewDocument(windowProvider.Object);

            windowProvider.Verify(i => i.Show(It.IsNotNull <string>(), It.IsNotNull <DocumentViewer>()), Times.Never);
        }
        public void FileName_InvalidCharacters_GetsRemoved()
        {
            var ppcoll = new PrintProcessorCollection(Enumerable.Empty<Printing.PrintProcessor.PrintProcessor>());
            var formattableString = $"Hello{Path.GetInvalidFileNameChars()[0]}Hello{Path.GetInvalidFileNameChars()[1]}";

            Assert.That(ppcoll.FileName, Is.Empty);

            ppcoll.FileName = formattableString;
            CollectionAssert.DoesNotContain(ppcoll.FileName, Path.GetInvalidFileNameChars());
        }
        public void FileName_InvalidCharacters_GetsRemoved()
        {
            var ppcoll            = new PrintProcessorCollection(Enumerable.Empty <Printing.PrintProcessor.PrintProcessor>());
            var formattableString = $"Hello{Path.GetInvalidFileNameChars()[0]}Hello{Path.GetInvalidFileNameChars()[1]}";

            Assert.That(ppcoll.FileName, Is.Empty);

            ppcoll.FileName = formattableString;
            CollectionAssert.DoesNotContain(ppcoll.FileName, Path.GetInvalidFileNameChars());
        }
        public void Ctor_SingleElement()
        {
            var p = new Mock<Printing.PrintProcessor.PrintProcessor>();
            PrintProcessorCollection pp = new PrintProcessorCollection(p.Object);

            Assert.That(pp.FileName, Is.EqualTo(p.Object.FileName));

            CollectionAssert.Contains(pp, p.Object);

            Assert.That(pp.Count, Is.EqualTo(1));
        }
        public void Ctor_SingleElement()
        {
            var p = new Mock <Printing.PrintProcessor.PrintProcessor>();
            PrintProcessorCollection pp = new PrintProcessorCollection(p.Object);

            Assert.That(pp.FileName, Is.EqualTo(p.Object.FileName));

            CollectionAssert.Contains(pp, p.Object);

            Assert.That(pp.Count, Is.EqualTo(1));
        }
Example #9
0
        public void PrintDoucment_CloseDialog_ReturnsFalse()
        {
            var printDialog = new Mock <IPrintDialog>();

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

            var testPrintProcessor = new TestPrintProcessor();

            testPrintProcessor.PrintDialog = printDialog.Object;
            var printProcessor = new PrintProcessorCollection(testPrintProcessor);

            Assert.That(printProcessor.PrintDocument(), Is.False);
        }
        public void PreviewDocument1()
        {
            var printDialog        = new Mock <IPrintDialog>();
            var testPrintProcessor = new TestPrintProcessor {
                PrintDialog = printDialog.Object
            };
            var printProcessor = new PrintProcessorCollection(testPrintProcessor);
            var windowProvider = new Mock <IWindowProvider>();

            printProcessor.PreviewDocument(windowProvider.Object);

            windowProvider.Verify(i => i.Show(It.IsNotNull <string>(), It.IsNotNull <DocumentViewer>()), Times.Once);
        }
        public void Ctor()
        {
            Mock<Printing.PrintProcessor.PrintProcessor>[] m1 =
            {
                new Mock<Printing.PrintProcessor.PrintProcessor>(),
                new Mock<Printing.PrintProcessor.PrintProcessor>(),
                new Mock<Printing.PrintProcessor.PrintProcessor>(),
                new Mock<Printing.PrintProcessor.PrintProcessor>()
            };
            PrintProcessorCollection pp = new PrintProcessorCollection(m1.Select(i => i.Object), "FileName");
            CollectionAssert.AreEqual(m1.Select(i => i.Object), pp);

            Assert.That(pp.FileName, Is.EqualTo("FileName"));
        }
        public void Ctor()
        {
            Mock <Printing.PrintProcessor.PrintProcessor>[] m1 =
            {
                new Mock <Printing.PrintProcessor.PrintProcessor>(),
                new Mock <Printing.PrintProcessor.PrintProcessor>(),
                new Mock <Printing.PrintProcessor.PrintProcessor>(),
                new Mock <Printing.PrintProcessor.PrintProcessor>()
            };
            PrintProcessorCollection pp = new PrintProcessorCollection(m1.Select(i => i.Object), "FileName");

            CollectionAssert.AreEqual(m1.Select(i => i.Object), pp);

            Assert.That(pp.FileName, Is.EqualTo("FileName"));
        }
        public void PrintDoucment_Direct_ReturnsTrue()
        {
            var printDialog = new Mock <IPrintDialog>();

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

            var testPrintProcessor = new TestPrintProcessor();
            var printProcessor     = new PrintProcessorCollection(testPrintProcessor);

            testPrintProcessor.PrintDialog = printDialog.Object;

            Assert.That(printProcessor.PrintDocument(), Is.True);
            Assert.That(printProcessor.PrintDocument(PrinterSettings.InstalledPrinters[0], new LocalPrintServer()), Is.True);
            Assert.That(printProcessor.PrintDocument(PrinterSettings.InstalledPrinters[0]), Is.True);
        }
        public FixedDocument CreateFixedDocument(PrintProcessorCollection collection)
        {
            FixedDocument = new FixedDocument();

            if (collection != null)
            {
                foreach (var pp in collection)
                {
                    var currentPage = FixedDocument.Pages.Count;
                    _printProcessor   = pp;
                    CurrentPageNumber = 1;
                    _printProcessor   = pp;
                    IList <IPrintContent> itemCollection = _printProcessor.ItemCollection().ToList();

                    AddItems(itemCollection);
                    if (collection.IndividualPageNumbers)
                    {
                        AddPageNumbers(currentPage);
                    }

                    for (int i = currentPage,
                         j = 1;
                         i < FixedDocument.Pages.Count;
                         i++, j++)
                    {
                        AddCustomPositionedContent(FixedDocument.Pages[i], _printProcessor.GetCustomPageContent(j));
                    }
                }

                if (!collection.IndividualPageNumbers)
                {
                    AddPageNumbers();
                }
            }
            return(FixedDocument);
        }
 public void PrintDocument_NoPrintProcessor_DoesNotPrint()
 {
     var ppcoll = new PrintProcessorCollection(Enumerable.Empty<Printing.PrintProcessor.PrintProcessor>());
     Assert.That(ppcoll.PrintDocument(), Is.False);
     Assert.That(ppcoll.PrintDocument(string.Empty), Is.False);
 }
        public void PrintDoucment_CloseDialog_ReturnsFalse()
        {
            var printDialog = new Mock<IPrintDialog>();
            printDialog.Setup(i => i.ShowDialog()).Returns(false);

            var testPrintProcessor = new TestPrintProcessor();
            testPrintProcessor.PrintDialog = printDialog.Object;
            var printProcessor = new PrintProcessorCollection(testPrintProcessor);

            Assert.That(printProcessor.PrintDocument(), Is.False);
        }
        public void PrintDoucment_Direct_ReturnsTrue()
        {
            var printDialog = new Mock<IPrintDialog>();
            printDialog.Setup(i => i.ShowDialog()).Returns(true);

            var testPrintProcessor = new TestPrintProcessor();
            var printProcessor = new PrintProcessorCollection(testPrintProcessor);

            testPrintProcessor.PrintDialog = printDialog.Object;

            Assert.That(printProcessor.PrintDocument(), Is.True);
            Assert.That(printProcessor.PrintDocument(PrinterSettings.InstalledPrinters[0], new LocalPrintServer()), Is.True);
            Assert.That(printProcessor.PrintDocument(PrinterSettings.InstalledPrinters[0]), Is.True);
        }
        public void FileName_Null_IsStringEmpty()
        {
            var ppcoll = new PrintProcessorCollection(Enumerable.Empty<Printing.PrintProcessor.PrintProcessor>());

            ppcoll.FileName = null;
            Assert.That(ppcoll.FileName, Is.Empty);
        }
        public void PreviewDocument1()
        {
            var printDialog = new Mock<IPrintDialog>();
            var testPrintProcessor = new TestPrintProcessor();
            testPrintProcessor.PrintDialog = printDialog.Object;
            var printProcessor = new PrintProcessorCollection(testPrintProcessor);
            var windowProvider = new Mock<IWindowProvider>();
            printProcessor.PreviewDocument(windowProvider.Object);

            windowProvider.Verify(i => i.Show(It.IsNotNull<string>(), It.IsNotNull<DocumentViewer>()), Times.Once);
        }
        public void PreviewDocument()
        {
            var printProcessor = new PrintProcessorCollection(Enumerable.Empty<Printing.PrintProcessor.PrintProcessor>());
            var windowProvider = new Mock<IWindowProvider>();

            printProcessor.PreviewDocument(windowProvider.Object);

            windowProvider.Verify(i => i.Show(It.IsNotNull<string>(), It.IsNotNull<DocumentViewer>()), Times.Never);
        }