Пример #1
0
        public void SendAllReports()
        {
            var reportBuilder = new Mock<IReportBuilder>();
            var reportSender = new Mock<IReportSender>();

            reportBuilder.Setup(m => m.CreateRegularReports())
                .Returns(new List<Report> {new Report(), new Report()});

            var reporter =  new Reporter(reportBuilder.Object, reportSender.Object);

            reporter.SendReports();

            reportSender.Verify(m => m.Send(It.IsAny<Report>()), Times.Exactly(2));
        }
Пример #2
0
        public void SendSpecialReportToAdministratorIfNoReportsCreated()
        {
            var reportBuilder = new Mock<IReportBuilder>();
            var reportSender = new Mock<IReportSender>();

            reportBuilder.Setup(m => m.CreateRegularReports()).Returns(new List<Report>());
            reportBuilder.Setup(m => m.CreateSpecialReport()).Returns(new SpecialReport());

            var reporter =  new Reporter(reportBuilder.Object, reportSender.Object);

            reporter.SendReports();

            reportSender.Verify(m => m.Send(It.IsAny<SpecialReport>()), Times.Once());
        }
Пример #3
0
        public void ReturnCountOfSentReports()
        {
            var reportBuilder = new Mock<IReportBuilder>();
            var reportSender = new Mock<IReportSender>();

            // задаем поведение для интерфейса IReportBuilder
            reportBuilder.Setup(m => m.CreateRegularReports())
                .Returns(new List<Report> {new Report(), new Report()});

            var reporter =  new Reporter(reportBuilder.Object, reportSender.Object);

            var reportCount = reporter.SendReports();

            Assert.Equal(2, reportCount);
        }