Ejemplo n.º 1
0
        public void PdfPreviewHandlerControlShouldAddValidInfoBarIfPdfPreviewThrows()
        {
            // Arrange
            using (var pdfPreviewHandlerControl = new PdfPreviewHandlerControl())
            {
                var mockStream = new Mock <IStream>();
                mockStream
                .Setup(x => x.Read(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <IntPtr>()))
                .Throws(new Exception());

                // Act
                pdfPreviewHandlerControl.DoPreview(mockStream.Object);
                var textBox = pdfPreviewHandlerControl.Controls[0] as RichTextBox;

                // Assert
                Assert.IsFalse(string.IsNullOrWhiteSpace(textBox.Text));
                Assert.AreEqual(1, pdfPreviewHandlerControl.Controls.Count);
                Assert.AreEqual(DockStyle.Top, textBox.Dock);
                Assert.AreEqual(Color.LightYellow, textBox.BackColor);
                Assert.IsTrue(textBox.Multiline);
                Assert.IsTrue(textBox.ReadOnly);
                Assert.AreEqual(RichTextBoxScrollBars.None, textBox.ScrollBars);
                Assert.AreEqual(BorderStyle.None, textBox.BorderStyle);
            }
        }
Ejemplo n.º 2
0
        public void PdfPreviewHandlerControlAddsControlsToFormWhenDoPreviewIsCalled()
        {
            // Arrange
            using (var pdfPreviewHandlerControl = new PdfPreviewHandlerControl())
            {
                // Act
                var file = File.ReadAllBytes("HelperFiles/sample.pdf");

                pdfPreviewHandlerControl.DoPreview <IStream>(GetMockStream(file));

                var flowLayoutPanel = pdfPreviewHandlerControl.Controls[0] as FlowLayoutPanel;

                // Assert
                Assert.AreEqual(1, pdfPreviewHandlerControl.Controls.Count);
            }
        }