Ejemplo n.º 1
0
        public void Create6Issues(int numberOfIssues)
        {
            Issue issue      = null;
            Issue priorIssue = null;

            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                for (int i = 0; i < numberOfIssues; i++)
                {
                    IssueTracker       issueTracker = (IssueTracker)session.Open(IssueTracker.PlaceInDatabase, 1, 1, false);
                    User               user         = issueTracker.UserSet.Keys[rand.Next(issueTracker.UserSet.Count)];
                    User               assignedTo   = issueTracker.UserSet.Keys[rand.Next(issueTracker.UserSet.Count)];
                    Project            project      = issueTracker.ProjectSet.Keys[rand.Next(issueTracker.ProjectSet.Count)];
                    Component          component    = issueTracker.ComponentSet.Keys[rand.Next(issueTracker.ComponentSet.Count)];
                    ProductVersion     version      = issueTracker.VersionSet.Keys[rand.Next(issueTracker.VersionSet.Count)];
                    Issue.CategoryEnum category     = (Issue.CategoryEnum)rand.Next(5);
                    Issue.Resolution   resolution   = (Issue.Resolution)rand.Next(5);
                    Issue.PriorityEnum priority     = (Issue.PriorityEnum)rand.Next(5);
                    Issue.StatusEnum   status       = (Issue.StatusEnum)rand.Next(5);
                    if (status == Issue.StatusEnum.Open || status == Issue.StatusEnum.InProgress || status == Issue.StatusEnum.Reopened)
                    {
                        resolution = Issue.Resolution.Incomplete; // the other states does not make sense
                    }
                    DateTime dueDate = new DateTime(rand.Next());
                    string   c       = "project" + i.ToString();
                    string   s       = "summary" + i.ToString();
                    string   e       = "environment" + i.ToString();
                    string   d       = "idescription" + i.ToString();
                    issue = new Issue(user, priority, project, category, component, version, resolution, s, d, e, assignedTo, dueDate, null, status);
                    issue.Persist(session, priorIssue == null ? issue : priorIssue);
                    priorIssue = issue;
                    issueTracker.Add(issue);
                }
                session.Commit();
            }
        }