예제 #1
0
        public void Can_Attach_1_For_Each_Already_Zipped()
        {
            _file.Setup(f => f.Exists(It.IsAny <string>())).Returns(true);
            var attacher = new Attacher(new ExceptionReportInfo {
                FilesToAttach = new[] { "file1.zip", "file2.zip" }
            })
            {
                File   = _file.Object,
                Zipper = _zip.Object
            };

            attacher.AttachFiles(_iAttach.Object);

            _iAttach.Verify(a => a.Attach("file1.zip"), Times.Once());
            _iAttach.Verify(a => a.Attach("file2.zip"), Times.Once());
        }
        public void Can_Attach_0_When_Multiple_Files_But_None_Exist()
        {
            _file.Setup((f) => f.Exists(It.IsAny <string>())).Returns(false);
            _file.Setup((f) => f.TempFile(It.IsAny <string>())).Returns("attach.zip");

            var attacher = new Attacher(new ExceptionReportInfo {
                FilesToAttach = new string[] { "file1", "file2", "file3" }
            })
            {
                File   = _file.Object,
                Zipper = _zip.Object
            };

            attacher.AttachFiles(_iattach.Object);

            _iattach.Verify((a) => a.Attach("attach.zip"), Times.Never());
        }
        public void Can_Attach_1_With_1_File()
        {
            _file.Setup((f) => f.Exists("file1")).Returns(true);
            _file.Setup((f) => f.TempFile(It.IsAny <string>())).Returns("attach.zip");

            var attacher = new Attacher(new ExceptionReportInfo {
                FilesToAttach = new string[] { "file1" }
            })
            {
                File   = _file.Object,
                Zipper = _zip.Object
            };

            attacher.AttachFiles(_iattach.Object);

            _iattach.Verify((a) => a.Attach("attach.zip"), Times.Once);
        }
        public void Can_Attach_1_With_Multiple_Files()
        {
            _file.Setup(f => f.Exists(It.IsAny <string>())).Returns(true);
            _file.Setup(f => f.TempFile(It.IsAny <string>())).Returns("attach.zip");

            var attacher = new Attacher(new ExceptionReportInfo {
                FilesToAttach = new[] { "file1", "file2", "file3" }
            }, new Mock <IScreenShooter>().Object)
            {
                FileService = _file.Object,
                Zipper      = _zip.Object
            };

            attacher.AttachFiles(_iAttach.Object);

            _iAttach.Verify(a => a.Attach("attach.zip"), Times.Once);
        }
예제 #5
0
        public void Should_Not_Take_Screenshot_If_Already_Taken()
        {
            var screenshot = new Mock <IScreenshotTaker>();

            using (var bm = new Bitmap(1, 1))
            {
                var attacher =
                    new Attacher(new ExceptionReportInfo
                {
                    TakeScreenshot  = true,
                    ScreenshotImage = bm                                        // this makes the screenshot "already taken" ie exists
                })
                {
                    ScreenshotTaker = screenshot.Object,
                };

                attacher.AttachFiles(_iattach.Object);
            }

            screenshot.Verify(s => s.TakeScreenShot(), Times.Never);
        }