/// <summary> /// Bind Report Data /// </summary> public void BindReport() { try { Dictionary<string, string> parameters = new Dictionary<string, string>(); IList<CS_View_DPIReport> reportData; using (_model = new DPIModel()) { reportData = _model.ListDPIReportInformation(_view.ReportView.Value, _view.ReportDate.Value); if (_view.ReportView == Globals.DPIReport.ReportView.NewJobs) { parameters.Add("MTD", _model.GetDPIReportMTDCount(_view.ReportDate.Value).ToString()); parameters.Add("YTD", _model.GetDPIReportYTDCount(_view.ReportDate.Value).ToString()); parameters.Add("TotalRevenue", _model.GetDPIReportTotalRevenue(_view.ReportDate.Value).ToString("$#,##0.00")); _view.NewJobsDataSource = reportData; } else { parameters.Add("TotalRevenue", _model.GetDPIReportContinuingTotalRevenue(_view.ReportDate.Value).ToString("$#,##0.00")); _view.ContinuingJobsDataSource = reportData; } _view.ReportParameters = parameters; } } catch (Exception ex) { Logger.Write(string.Format("An error has ocurred while trying to bind the Report!\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("An error ocurred while trying to bind the Report.", false); } }
public void MustReturnCorrectMTDCountOnDPI() { //Arrange FakeObjectSet<CS_DPI> fakeDPI = new FakeObjectSet<CS_DPI>(); fakeDPI.AddObject(new CS_DPI() { ID = 1, JobID = 1, Date = new DateTime(2011,07,25), Active = true, ProcessStatus = (int)Globals.DPI.DpiStatus.Approved }); fakeDPI.AddObject(new CS_DPI() { ID = 1, JobID = 1, Date = new DateTime(2011, 07, 30), Active = true, ProcessStatus = (int)Globals.DPI.DpiStatus.Approved }); fakeDPI.AddObject(new CS_DPI() { ID = 1, JobID = 1, Date = new DateTime(2011, 08, 10), Active = true, ProcessStatus = (int)Globals.DPI.DpiStatus.Approved }); fakeDPI.AddObject(new CS_DPI() { ID = 1, JobID = 1, Date = new DateTime(2011, 08, 13), Active = true, ProcessStatus = (int)Globals.DPI.DpiStatus.Approved }); fakeDPI.AddObject(new CS_DPI() { ID = 1, JobID = 2, Date = new DateTime(2011, 08, 20), Active = true, ProcessStatus = (int)Globals.DPI.DpiStatus.Approved }); Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_DPI>()).Returns(fakeDPI); DateTime currentDate = new DateTime(2011, 08, 15); DPIModel model = new DPIModel(mockUnitOfWork.Object); //Act int count = model.GetDPIReportMTDCount(currentDate); //Assert Assert.AreEqual(1, count); }