示例#1
0
        public void ReportLogic_EditReport_SuccessfullDone()
        {
            Mock <IReportDAO> mockDAO = new Mock <IReportDAO>();

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

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

            logic.Edit(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);
        }
        public void ReportController_ThrowExceptionDuringSubmittingInternsReportAfterAddition_ReturnPartialView()
        {
            Mock <IReportLogic> mockLogic = new Mock <IReportLogic>();

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

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

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

            ReportVM         internsReportVM = ReportProvider.GetCorrectInternsReportVM();
            ReportController reportCrtl      = new ReportController(mockLogic.Object, Mock.Of <IUserLogic>(), mockLogger.Object);

            ActionResult result = reportCrtl.SubmitReportAfterAddition(internsReportVM);

            Assert.IsNotNull(result);
            Assert.IsAssignableFrom(typeof(PartialViewResult), result);

            mockLogger.VerifyAll();
        }