예제 #1
0
        public void ReportLogic_AddReport_SuccessfullDone()
        {
            Mock <IReportDAO> mockDAO = new Mock <IReportDAO>();

            mockDAO.Setup(t => t.Add(It.IsAny <Report>())).Verifiable();

            ReportLogic logic         = new ReportLogic(mockDAO.Object, Mock.Of <IUserDAO>(), Mock.Of <ICustomLogger>());
            Report      correctReport = ReportProvider.GetCorrectInternsReport();

            logic.Add(correctReport);

            mockDAO.VerifyAll();
        }
예제 #2
0
        public void ReportLogic_ThrowExceptionDuringAdditionReport_ThrowException()
        {
            Mock <IReportDAO> mockDAO = new Mock <IReportDAO>();

            mockDAO.Setup(t => t.Add(It.IsAny <Report>())).Throws <Exception>();

            Mock <ICustomLogger> loggerMock = new Mock <ICustomLogger>();

            loggerMock.Setup(t => t.RecordError(It.IsAny <Exception>())).Verifiable();

            Report      correctReport = ReportProvider.GetCorrectInternsReport();
            ReportLogic logic         = new ReportLogic(mockDAO.Object, Mock.Of <IUserDAO>(), loggerMock.Object);

            Assert.Throws <Exception>(() => logic.Add(correctReport));

            loggerMock.Verify(t => t.RecordError(It.IsAny <Exception>()), Times.Once);
        }