/// <summary> /// Checks whether there is already a status report in the database for the rolled date. Rolling /// won't automatically delete an existing report. /// </summary> /// <param name="report"></param> /// <param name="statusRollDate">Output parameter for the date this will be rolled to if valid.</param> /// <returns></returns> public bool CanRollStatusReport(StatusReport report, out DateTime statusRollDate) { statusRollDate = this.RollStatusDateProcessor.GetStatusReportDate(report.PeriodStart); var sr = this.StatusReportRepository.GetStatusReport(statusRollDate); bool canRoll = (sr == null); _logger.Debug("CanRollStatusReport called for {0:yyyy-mm-dd} and returned {1}", statusRollDate, canRoll); return canRoll; }
public void CaptionTest() { StatusReport target = new StatusReport(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; target.Caption = expected; actual = target.Caption; Assert.AreEqual(expected, actual); }
public void AddStatusItemTest1() { StatusReport target = new StatusReport(); // TODO: Initialize to an appropriate value StatusItem statusItem = new StatusItem() {Caption = "Test Status Item"}; // TODO: Initialize to an appropriate value target.AddStatusItem(statusItem); Assert.AreEqual(1, target.Items.Count); StatusItem si = target.Items[0]; Assert.AreSame(statusItem, si); }
public void AddStatusItemTest() { StatusReport target = new StatusReport(); // TODO: Initialize to an appropriate value Topic statusTopic = new Topic() {Caption = "Test Topic"}; // TODO: Initialize to an appropriate value target.AddStatusItem(statusTopic); Assert.AreEqual(1, target.Items.Count); StatusItem si = target.Items[0]; Assert.AreEqual(statusTopic.Caption, si.Caption); }
/// <summary> /// Rolls the status report to the default date handled by the StatusRollProcessor /// </summary> /// <param name="report"></param> /// <param name="auditInfo"> </param> public StatusReport RollStatusReport(StatusReport report, AuditInfo auditInfo) { DateTime statusRollDate; if (!CanRollStatusReport(report, out statusRollDate)) throw new Exception("StatusReport already exists, cannot roll to that date"); _logger.Debug("Rolling status report from {0:yyyy-mm-dd} started", report.PeriodStart); var rolledReport = new StatusReport { Caption = report.Caption, PeriodStart = statusRollDate, AuditInfo = auditInfo }; report.Items.ToList().ForEach( si => { var mappedItem = RollStatusProcessor.MapStatusItem(si, rolledReport.PeriodStart); // somehow the topic (and project too?) is an issue when mapping this item and storing via // nhibernate. the statusreport needs to share the same session. if (mappedItem != null) rolledReport.Items.Add(mappedItem); }); // var sess = this.StatusReportRepository.Session; using (var txn = this.StatusReportRepository.BeginTransaction()) { try { this.StatusReportRepository.Update(rolledReport); txn.Commit(); } catch (Exception exc) { _logger.ErrorException("RollStatusReport error", exc); txn.Rollback(); throw; } } _logger.Info("Rolled status report from {0:yyyy-mm-dd} to {1:yyyy-mm-dd}", report.PeriodStart, rolledReport.PeriodStart); return rolledReport; }
public void IdTest() { StatusReport target = new StatusReport(); // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; target.Id = expected; actual = target.Id; Assert.AreEqual(expected, actual); }
public void StatusReportConstructorTest() { StatusReport target = new StatusReport(); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void PeriodStartTest() { StatusReport target = new StatusReport(); // TODO: Initialize to an appropriate value DateTime expected = new DateTime(); // TODO: Initialize to an appropriate value DateTime actual; target.PeriodStart = expected; actual = target.PeriodStart; Assert.AreEqual(expected, actual); }
public void ItemsTest() { StatusReport target = new StatusReport(); // TODO: Initialize to an appropriate value Assert.IsNotNull(target.Items); }
internal virtual IStatusReport CreateIStatusReport() { // TODO: Instantiate an appropriate concrete class. IStatusReport target = new StatusReport(); return target; }
private StatusReportViewModel GetStatusReportViewModel(StatusReport data) { var statusReportDate = data.PeriodStart; var vm = Mapper.Map<StatusReport, StatusReportViewModel>(data); // populate the recent dates if (vm != null) vm.StatusReportDates = this.StatusReportRepository.GetAllStatusReportDates(); // determine whether we can roll status this.StatusReportManager.RollStatusDateProcessor.GetStatusReportDate(statusReportDate); DateTime statusRollDate; vm.CanRollStatus = this.StatusReportManager.CanRollStatusReport(data, out statusRollDate); if (vm.CanRollStatus) vm.RollStatusDate = statusRollDate; // get project names IList<Project> projects = this.ProjectRepository.GetAllProjects(); vm.Projects = Mapper.Map<IList<Project>, IList<ProjectViewModel>>(projects); IList<Tag> tags = this.TagRepository.GetAllTags(); vm.Tags = Mapper.Map<IList<Tag>, IList<TagViewModel>>(tags); //vm.Projects = this.ProjectRepository.GetAllProjects().Select(p => new { // Name = p.Name, Id = p.Id, TeamLeadId = p.Team.Lead.Id }).ToList(); return vm; }
/// <summary> /// Creates an instance of the StatusReport. /// </summary> /// <param name="statusReportDate"></param> /// <param name="caption"></param> /// <returns></returns> public static StatusReport Create(DateTime statusReportDate, string caption) { var sr = new StatusReport() {PeriodStart = statusReportDate, Caption = caption}; return sr; }
public void StatusReportCascadingPersistenceTest() { const string caption1 = "Status Item StatusReportCascadingPersistenceTest"; const string caption2 = "2-Status Item StatusReportCascadingPersistenceTest"; var factory = _config.CreateSessionFactory(); int srId = 0; Project project = null; Topic topic2 = null; using (var session = factory.OpenSession()) { using (var txn = session.BeginTransaction()) { var employee = new Employee { FirstName = "Dave", LastName = "Neigler", EmailAddress = "*****@*****.**" }; session.SaveOrUpdate(employee); var team = new Team { Lead = employee, Name = "Test Team" }; session.SaveOrUpdate(team); var department = new Department { Name = "Operations IT" }; session.SaveOrUpdate(department); project = new Project { Name = "Test Project StatusReportCascadingPersistenceTest", StartDate = DateTime.Parse("01/01/2012"), EndDate = DateTime.Parse("07/01/2012"), Description = "Test project description", JiraProject = "TESTPROJ", Team = team, Type = ProjectType.Grow, Department = department }; session.SaveOrUpdate(project); var topic1 = new JiraIssueTopic { JiraId = "BOTEST-StatusReportCascadingPersistenceTest", Caption = "This is the caption" }; session.SaveOrUpdate(topic1); topic2 = new JiraIssueTopic { JiraId = "2-BOTEST-StatusReportCascadingPersistenceTest", Caption = "This is the second caption" }; session.SaveOrUpdate(topic2); var sr = new StatusReport() { Caption = "Test Status Report 1", PeriodStart = new DateTime(2012, 1, 1), PeriodEnd = new DateTime(2012, 1, 7) }; sr.Items.Add(new StatusItem { Caption = caption1, Milestone = new Milestone() { ConfidenceLevel = MilestoneConfidenceLevels.Proposed, Type = MilestoneTypes.OpenItem }, Topic = topic1, Project = project }); session.SaveOrUpdate(sr); srId = sr.Id; Assert.AreNotEqual(0, srId); txn.Commit(); } using (var txn = session.BeginTransaction()) { var sr = (from r in session.Query<StatusReport>() where r.Id == srId select r).FirstOrDefault(); var statusItem = (from si in session.Query<StatusItem>() where si.Caption.Equals(caption1) select si).FirstOrDefault(); Assert.IsNotNull(statusItem); Assert.IsNotNull(statusItem.Project); Assert.IsNotNull(statusItem.Topic); // now we add more items and see if it updates properly sr.Items.Add(new StatusItem { Caption = caption2, Milestone = new Milestone() { ConfidenceLevel = MilestoneConfidenceLevels.Proposed, Type = MilestoneTypes.OpenItem }, Topic = topic2, Project = project }); session.SaveOrUpdate(sr); var statusItem2 = (from si in session.Query<StatusItem>() where si.Caption.Equals(caption2) select si).FirstOrDefault(); Assert.IsNotNull(statusItem2); Assert.IsNotNull(statusItem2.Project); Assert.IsNotNull(statusItem2.Topic); txn.Commit(); } } }
public void RollStatusReportTest() { Mapper.CreateMap<StatusItem, StatusItem>(); var target = _kernel.Get<StatusReportManager>(); var items = new List<StatusItem>(); target.StatusReportRepository = _statusReportRepository; var proj = _projectRepository.GetAllProjects()[0]; StatusItem si1 = new StatusItem() { Caption = "Test1", Milestone = new Milestone() { ConfidenceLevel = MilestoneConfidenceLevels.High, Date = new DateTime(2011, 1, 1), Type = MilestoneTypes.Milestone }, Notes = new List<Note>(), Topic = new Topic() { Caption = "test Topic 1" }, Project = proj, AuditInfo = _auditInfo }; StatusItem si2 = Mapper.Map<StatusItem, StatusItem>(si1); si2.Milestone.Date = new DateTime(2011, 1, 10); StatusItem si3 = Mapper.Map<StatusItem, StatusItem>(si1); si3.Milestone.Date = new DateTime(2011, 2, 1); items.Add(si1); items.Add(si2); items.Add(si3); var report = new StatusReport { Caption = "Test 1", PeriodStart = new DateTime(2011, 01, 01) }; items.ForEach(report.AddStatusItem); StatusReport actual = target.RollStatusReport(report, _auditInfo); Assert.AreEqual(report.Caption, actual.Caption); Assert.AreEqual(report.Items.Count, actual.Items.Count); Assert.AreEqual(report.Items[0], si1); Assert.AreEqual(report.Items[1], si2); Assert.AreEqual(report.Items[2], si3); Assert.AreEqual(new DateTime(2011, 01, 03), actual.PeriodStart); Assert.AreEqual(0, report.Items[0].Id); Assert.AreEqual(0, report.Items[1].Id); Assert.AreEqual(0, report.Items[2].Id); // cleanup _statusReportRepository.DeleteStatusReport(new DateTime(2011, 1, 3)); }