public virtual void AddStatusItem(Topic statusTopic)
 {
     // validate that the status topic isn't already assigned to the report?
     // otherwise we have more than one status item being assigned which may cause confusion - but also may be limiting
     var si = new StatusItem(statusTopic);
     this.Items.Add(si);
 }
        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 MilestoneTest()
 {
     StatusItem target = new StatusItem(); // TODO: Initialize to an appropriate value
     Milestone expected = null; // TODO: Initialize to an appropriate value
     Milestone actual;
     target.Milestone = expected;
     actual = target.Milestone;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void IdTest()
 {
     StatusItem target = new StatusItem(); // 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);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void CaptionTest()
 {
     StatusItem target = new StatusItem(); // 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);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
        public StatusItem MapStatusItem(StatusItem sourceStatusItem, DateTime statusReportDate)
        {
            Mapper.CreateMap<StatusItem, StatusItem>();

            var si = new StatusItem();
            Mapper.Map(sourceStatusItem, si);
            // this is a good place for windows workflow to simplify management of transfering milestone types
            if (sourceStatusItem.Milestone.Date < statusReportDate.AddDays(-7))
                return null;
            if (sourceStatusItem.Milestone.Date < statusReportDate)
                si.Milestone.Type = MilestoneTypes.LastWeek;
            else if (sourceStatusItem.Milestone.Date >= statusReportDate &&
                     sourceStatusItem.Milestone.Date < statusReportDate.AddDays(7))
                si.Milestone.Type = MilestoneTypes.ThisWeek;
            //else if (sourceStatusItem.Milestone.Type != MilestoneTypes.Milestone &&
            //         sourceStatusItem.Milestone.Type != MilestoneTypes.OpenItem)
            //    si.Milestone.Type = MilestoneTypes.Milestone;
            return si;
        }
 public void MapStatusItemTestCurrentToLastWeek()
 {
     var target = new DefaultRollStatusProcessor();
     var sourceStatusItem = new StatusItem
                                       {
                                           Caption = "Test",
                                           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" }
                                       };
     var statusReportDate = new DateTime(2011, 1, 3);
     var actual = target.MapStatusItem(sourceStatusItem, statusReportDate);
     Assert.AreEqual(sourceStatusItem.Caption, actual.Caption);
     Assert.AreEqual(sourceStatusItem.Notes.Count, actual.Notes.Count);
     Assert.AreEqual(sourceStatusItem.Topic.Caption, actual.Topic.Caption);
     Assert.AreEqual(MilestoneTypes.LastWeek, actual.Milestone.Type);
     Assert.AreEqual(sourceStatusItem.Milestone.ConfidenceLevel, actual.Milestone.ConfidenceLevel);
     Assert.AreEqual(sourceStatusItem.Milestone.Date, actual.Milestone.Date);
 }
 public void NotesTest()
 {
     StatusItem target = new StatusItem(); // TODO: Initialize to an appropriate value
     Assert.IsNotNull(target.Notes);
 }
 public void StatusItemConstructorTest1()
 {
     StatusItem target = new StatusItem();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
 public void StatusItemConstructorTest()
 {
     Topic statusTopic = null; // TODO: Initialize to an appropriate value
     StatusItem target = new StatusItem(statusTopic);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Exemple #11
0
 public virtual void AddStatusItem(StatusItem statusItem)
 {
     this.Items.Add(statusItem);
 }
Exemple #12
0
        public void BasicPersistenceTest()
        {
            Assert.IsTrue(true, "RanTestMethod1");
            var factory = _config.CreateSessionFactory();
            using (var session = factory.OpenSession())
            {
                var project = new Project
                {
                    Name = "Test Project 1",
                    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
                };
                var project2 = new Project
                {
                    Name = "Test Project 2",
                    StartDate = DateTime.Parse("01/01/2012"),
                    EndDate = DateTime.Parse("07/01/2012"),
                    Description = "Test project 2 description",
                    JiraProject = "TESTPROJ2",
                    Team = _team,
                    Type = ProjectType.Grow,
                    Department = _department
                };

                var topic1 = new JiraIssueTopic
                {
                    JiraId = "BOTEST-1",
                    Caption = "This is the caption"
                };
                var topic2 = new JiraProjectTopic
                {
                    JiraProjectId = "PROJ-1",
                    Caption = "Test project"
                };
                var topic3 = new Topic
                {
                    Caption = "Standard topic"
                };
                var status1 = new StatusItem
                {
                    Caption = "Status",
                    Topic = topic1
                };
                var status2 = new StatusItem
                {
                    Topic = topic2
                };
                var status3 = new StatusItem
                {
                    Topic = topic3
                };
                session.Save(project);
                session.Save(project2);
                session.Save(topic1);
                session.Save(topic2);
                session.Save(topic3);
                session.Save(status1);
                session.Save(status2);
                session.Save(status3);
                Assert.AreNotEqual(topic1.Caption, status1.Caption);
                Assert.AreEqual(topic2.Caption, status2.Caption);
                Assert.AreEqual(topic3.Caption, status3.Caption);
                // delete status shouldn't remove topic
                session.Delete(status3);
                var topicRetVal3 = session.Get<Topic>(topic3.Id);
                Assert.IsNotNull(topicRetVal3);
            }

            using (var session2 = factory.OpenSession())
            {
                var project = session2.Get<Project>(1);
                Assert.IsNotNull(project);
                Assert.AreEqual<string>(project.Department.Name, "Operations IT");

                var projects = session2.Query<Project>()
                    .OrderBy(c => c.Name)
                    .ToList();
                Assert.AreEqual(2, projects.Count);

            }
        }
        public void UpsertStatus(IList<StatusCsvItem> items)
        {
            _logger.Info("UpsertStatus called for {0} items", items.Count);

            // we'll be sharing a single unitofwork for this operation
            ITransaction transaction = this.StatusReportRepository.BeginTransaction();

            // share the session - ugly
            this.ResourceRepository.Session = this.ProjectRepository.Session = this.DepartmentRepository.Session = this.TeamRepository.Session = this.TopicRepository.Session = this.StatusReportRepository.Session;
            try
            {
                Resource dummyResource;
                Department department;
                InitializeHelper(out dummyResource, out department);

                // create all resources
                // ensure all resources are in place
                // for now, we put a stub resource in this
                var grpResources = items.GroupBy(item => item.TeamLead);
                foreach (var resourceG in grpResources)
                {
                    var resources = this.ResourceRepository.GetResourcesByName(resourceG.Key);

                    var resEmp = resourceG.First();

                    var emp = new Employee() { FullName = resEmp.TeamLead, EmailAddress = String.Format("{0}@test.com", resourceG.Key.Replace(" ", ".")) };

                    // group by team for resource
                    var resByTeam = resourceG.GroupBy(rg => rg.TeamName);
                    resByTeam.ToList().ForEach(rbt =>
                    {
                        // while grouping by team, we don't care for the key, it can be pulled from alloc entry
                        var res = rbt.First(); // resourceG.ToList().First();

                        var team = this.TeamRepository.GetTeamByName(res.TeamName);
                        if (team == null)
                        {
                            // pull the details of team name / lead from first item
                            // lookup lead by eamil address?
                            var t = new Team() { Name = res.TeamName, Lead = emp, Department = department };
                            t.Members.Add(emp);
                            team = this.TeamRepository.Add(t);
                            if (emp.Team == null)
                                emp.Team = team;
                            // this.ResourceRepository.Update(rmp);
                        }

                        if (resources.Count == 0)
                            this.ResourceRepository.AddResource(emp);
                    });

                }

                // things to check
                // all projects exist and project id's returned
                var grpProjects = items.GroupBy(item => item.Project);
                foreach (var projectG in grpProjects)
                {
                    var p = this.ProjectRepository.GetProjectByName(projectG.Key);
                    if (p == null)
                    {
                        var pItem = projectG.First(); // is it possible to miss anything this way?
                        var pTeam = this.TeamRepository.GetTeamByName(pItem.TeamName); // not going to work with this file format as team id is made up
                        var pLead = this.ResourceRepository.GetResourcesByName(pItem.TeamLead).First();
                        var project = new Project() {
                            Name = pItem.Project,
                            Caption = pItem.Project, // ProjectSummary appears to be the budget
                            Lead=pLead as Employee,
                            Department = department,
                            Team = pTeam
                        };
                        decimal b;
                        if (Decimal.TryParse(pItem.ProjectSummary, out b))
                            project.Budget = b;
                        this.ProjectRepository.AddProject(project);
                    }
                }

                // map JIRA ID's to topics in the new system
                var grpTopics = items.GroupBy(item => item.JiraID);

                grpTopics.ToList().ForEach(
                    gt =>
                    {
                        var jiraId = gt.Key;
                        // empty strings are inevitable, create new topics for them
                        Topic t = null;
                        if (jiraId != string.Empty)
                        {
                            t = this.TopicRepository.GetTopicByExternalId(jiraId);
                            if (t == null)
                            {
                                // steal the topic from the first item in list
                                var firstItem = gt.First();
                                this.TopicRepository.Add(new JiraIssueTopic() { JiraId = jiraId, Caption = firstItem.Note });
                            }
                        }
                        else
                        {
                            // all the empty topics will be grouped together, so if that is the case, create as new topics now
                            gt.ToList().ForEach(item => this.TopicRepository.Add(new Topic() { Caption = item.Note }));
                        }

                    });

                // get all status dates to see if we are overwriting an existing report, if so, delete the old one
                var grpStatusDates = items.GroupBy(item => item.StatusDate);

                // the following should be done in a transaction.
                grpStatusDates.ToList().ForEach(
                    gsd =>
                    {
                        var statusReportDate = gsd.Key;
                        try { this.StatusReportRepository.DeleteStatusReport(statusReportDate); }
                        catch (NullReferenceException) { }
                        var statusReport = StatusReport.Create(statusReportDate, String.Format("Status report for {0:MM/dd/yyyy}", statusReportDate));
                        statusReport.AuditInfo = new AuditInfo(dummyResource);
                        // iterate through each item for that date and add them
                        gsd.ToList().ForEach(statusReportItem =>
                                                 {
                                                     // we need to construct statusitem and topic for this
                                                     var statusItem = new StatusItem();
                                                     // we could use AutoMapper here - but doing manually for now as custom logic abound
                                                     statusItem.Topic = this.TopicRepository.GetTopicByExternalId(statusReportItem.JiraID);
                                                     if (statusItem.Topic == null)
                                                         statusItem.Topic = this.TopicRepository.GetTopicByCaption(statusReportItem.Note);

                                                     statusItem.Project = this.ProjectRepository.GetProjectByName(statusReportItem.Project);
                                                     statusItem.AuditInfo = new AuditInfo(dummyResource);
                                                     statusItem.Milestone = new Milestone()
                                                     {
                                                         ConfidenceLevel = statusReportItem.MilestoneConfidence ?? MilestoneConfidenceLevels.High,
                                                         Date = statusReportItem.MilestoneDate,
                                                         Type = statusReportItem.StatusType
                                                     };
                                                     statusItem.Caption = statusReportItem.Note; //.Caption;
                                                     statusItem.Notes.Add(new Note()
                                                                              {
                                                                                  AuditInfo = new AuditInfo(dummyResource),
                                                                                  Text = statusReportItem.Note
                                                                              });
                                                     if (statusItem.Topic != null)
                                                     {
                                                         statusReport.AddStatusItem(statusItem);
                                                         statusItem.StatusReport = statusReport;
                                                     }
                                                     else
                                                         _logger.Warn("Skilling statusitem {0} as no topic assigned", statusItem.Caption);
                                                 });
                        this.StatusReportRepository.AddStatusReport(statusReport);
                    });
                // import the new status report items

                this.StatusReportRepository.CommitTransaction();
            }
            catch (Exception exc)
            {
                _logger.ErrorException("Unable to import from CsvStatus file", exc);
                this.StatusReportRepository.RollbackTransaction();
                throw;
            }
            finally
            {
            }
        }
        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));
        }
 public void MapStatusItemTestElse()
 {
     var target = new DefaultRollStatusProcessor();
     var sourceStatusItem = new StatusItem
     {
         Caption = "Test",
         Milestone = new Milestone()
         {
             ConfidenceLevel = MilestoneConfidenceLevels.High,
             Date = new DateTime(2011, 1, 1),
             Type = MilestoneTypes.LastWeek
         },
         Notes = new List<Note>(),
         Topic = new Topic() { Caption = "Test Topic" }
     };
     var statusReportDate = sourceStatusItem.Milestone.Date.Value.AddDays(1);
     var actual = target.MapStatusItem(sourceStatusItem, statusReportDate);
     Assert.AreEqual(sourceStatusItem.Milestone.Type, actual.Milestone.Type);
 }