Beispiel #1
0
        public void Should_Get_Project()
        {
            var project = redmineManager.GetObject <Project>(PROJECT_IDENTIFIER, null);

            Assert.IsNotNull(project, "Get project returned null.");
            Assert.IsInstanceOfType(project, typeof(Project), "Entity is not of type project.");
        }
Beispiel #2
0
        public void RedmineTimeEntries_ShouldGetEntityById()
        {
            var timeEntryId = "19";

            var timeEntry = redmineManager.GetObject <TimeEntry>(timeEntryId, null);

            Assert.IsNotNull(timeEntry);
        }
        public void RedmineProjectVersion_ShouldGetVersionById()
        {
            var versionId = "12";

            Redmine.Net.Api.Types.Version version = redmineManager.GetObject <Redmine.Net.Api.Types.Version>(versionId, null);

            Assert.IsNotNull(version);
        }
Beispiel #4
0
        public void RedmineProjectMembership_ShouldGetById()
        {
            string pmId = "104";

            var projectMembership = redmineManager.GetObject <ProjectMembership>(pmId, null);

            Assert.IsNotNull(projectMembership);
        }
        public void RedmineIssueRelation_ShouldGetRelationById()
        {
            string relationId = "20";

            var relation = redmineManager.GetObject <IssueRelation>(relationId, null);

            Assert.IsNotNull(relation);
        }
        public void RedmineAttachments_ShouldGetById()
        {
            string attachmentId = "10";

            var attachment = redmineManager.GetObject <Attachment>(attachmentId, null);

            Assert.IsNotNull(attachment);
        }
Beispiel #7
0
        public void RedmineIssueCategory_ShouldGetIssueCategoryById()
        {
            var issueCategoryId = "12";

            IssueCategory issueCategory = redmineManager.GetObject <IssueCategory>(issueCategoryId, null);

            Assert.IsNotNull(issueCategory);
            Assert.IsTrue(issueCategory.AsignTo.Name.Contains("Alina"));
        }
        public void Should_Get_IssueRelation_By_Id()
        {
            var relation = redmineManager.GetObject <IssueRelation>(RELATION_ID_TO_GET, null);

            Assert.IsNotNull(relation, "Get issue relation returned null.");
            Assert.AreEqual(relation.IssueId, RELATED_ISSUE_ID, "Related issue id is not valid.");
            Assert.AreEqual(relation.IssueToId.ToString(), ISSUE_ID, "Issue id is not valid.");
            Assert.AreEqual(relation.Delay, RELATION_DELAY, "Delay is not valid.");
            Assert.AreEqual(relation.Type, OPPOSED_RELATION_TYPE, "Relation type is not valid.");
        }
 public static string FindIssue(int IssueId)
 {
     Console.WriteLine(DateTime.Now + ": ServerClass.FindIssue: " + IssueId);
     try
     {
         Issues = redmine.GetObject <Issue>(Convert.ToString(IssueId), parameters2);
         return(Issues.Subject);
     }
     catch { return(""); }
 }
        public void GetGroup_With_Memberships()
        {
            var result = redmineManager.GetObject <Group>("9", new NameValueCollection()
            {
                { "include", "memberships" }
            });

            Assert.IsNotNull(result);
        }
        public void GetProject_WithAll_AssociatedData()
        {
            var result = redmineManager.GetObject <Project>("9", new NameValueCollection()
            {
                { "include", "trackers, issue_categories, enabled_modules" }
            });

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Project));
            Assert.IsNotNull(result.Trackers, "result.Trackers != null");
            Assert.IsNotNull(result.IssueCategories, "result.IssueCategories != null");
            Assert.IsNotNull(result.EnabledModules, "result.EnabledModules != null");
        }
Beispiel #12
0
        public async Task Should_Add_User_To_Group()
        {
            await redmineManager.AddUserToGroupAsync(groupId, int.Parse(userId));

            User user = redmineManager.GetObject <User>(userId.ToString(CultureInfo.InvariantCulture), new NameValueCollection {
                { RedmineKeys.INCLUDE, RedmineKeys.GROUPS }
            });

            CollectionAssert.AllItemsAreNotNull(user.Groups);
            CollectionAssert.AllItemsAreUnique(user.Groups);

            Assert.IsTrue(user.Groups.FirstOrDefault(g => g.Id == groupId) != null);
        }
Beispiel #13
0
        public void RedmineUser_ShouldGetUserById()
        {
            User user = redmineManager.GetObject <User>(userId, new NameValueCollection {
                { "include", "groups,memberships" }
            });

            Assert.AreEqual(user.Login, userLogin);
        }
Beispiel #14
0
        public void Should_Get_Issue_By_Id()
        {
            var issue = redmineManager.GetObject <Issue>(ISSUE_ID, new NameValueCollection {
                { RedmineKeys.INCLUDE, RedmineKeys.CHILDREN + "," + RedmineKeys.ATTACHMENTS + "," + RedmineKeys.RELATIONS + "," + RedmineKeys.CHANGESETS + "," + RedmineKeys.JOURNALS + "," + RedmineKeys.WATCHERS }
            });

            Assert.IsNotNull(issue, "Returned issue is null.");
            //TODO: add conditions for all associated data if nedeed
        }
Beispiel #15
0
        public void RedmineIssues_ShouldReturnIssueById()
        {
            var issue = redmineManager.GetObject <Issue>(issueId, new NameValueCollection {
                { "include", "children,attachments,relations,changesets,journals,watchers" }
            });

            Assert.IsNotNull(issue);
            //TODO: add conditions for all associated data
        }
        public void RedmineRoles_ShouldGetRoleById()
        {
            var roleId = 4;

            Role adminRole = redmineManager.GetObject <Role>(roleId.ToString(), null);

            Assert.AreEqual(adminRole.Name, "Admins");
        }
Beispiel #17
0
        public void Should_Upload_Attachment()
        {
            //read document from specified path
            byte[] documentData = File.ReadAllBytes(ATTACHMENT_LOCAL_PATH);

            //upload attachment to redmine
            Upload attachment = redmineManager.UploadFile(documentData);

            //set attachment properties
            attachment.FileName    = ATTACHMENT_NAME;
            attachment.Description = ATTACHMENT_DESCRIPTION;
            attachment.ContentType = ATTACHMENT_CONTENT_TYPE;

            //create list of attachments to be added to issue
            IList <Upload> attachments = new List <Upload>();

            attachments.Add(attachment);

            Issue issue = new Issue();

            issue.Project = new Project {
                Id = PROJECT_ID
            };
            issue.Subject = ISSUE_SUBJECT;
            issue.Uploads = attachments;

            //create issue and attach document
            Issue issueWithAttachment = redmineManager.CreateObject <Issue>(issue);

            issue = redmineManager.GetObject <Issue>(issueWithAttachment.Id.ToString(), new NameValueCollection {
                { RedmineKeys.INCLUDE, RedmineKeys.ATTACHMENTS }
            });

            Assert.IsNotNull(issue, "Get created issue returned null.");
            Assert.IsNotNull(issue.Attachments, "Attachments list is null.");
            CollectionAssert.AllItemsAreNotNull(issue.Attachments.ToList(), "Attachments list contains null items.");
            CollectionAssert.AllItemsAreInstancesOfType(issue.Attachments.ToList(), typeof(Attachment), "Attachments contains items of unexpected type.");
            Assert.IsTrue(issue.Attachments.Count == 1, "Number of attachments != 1");
            Assert.IsTrue(issue.Attachments[0].FileName == ATTACHMENT_NAME, "Attachment name is not correct.");
            Assert.IsTrue(issue.Attachments[0].Description == ATTACHMENT_DESCRIPTION, "Attachment description is not correct.");
            Assert.IsTrue(issue.Attachments[0].ContentType == ATTACHMENT_CONTENT_TYPE, "Attachment content type is not correct.");
        }
Beispiel #18
0
        public void Should_Get_Group_With_Memberships()
        {
            var group = redmineManager.GetObject <Group>(GROUP_ID, new NameValueCollection()
            {
                { RedmineKeys.INCLUDE, RedmineKeys.MEMBERSHIPS }
            });

            Assert.IsNotNull(group, "Get group by id returned null.");
            CollectionAssert.AllItemsAreInstancesOfType(group.Memberships.ToList(), typeof(Membership), "Not all items are of type membership.");
            CollectionAssert.AllItemsAreNotNull(group.Memberships.ToList(), "Memberships contains null items.");
            CollectionAssert.AllItemsAreUnique(group.Memberships.ToList(), "Memberships items are not unique.");
            Assert.IsTrue(group.Memberships.Count == NUMBER_OF_MEMBERSHIPS, "Number of memberships != " + NUMBER_OF_MEMBERSHIPS);
        }
Beispiel #19
0
        public void Should_Get_Role_By_Id()
        {
            Role role = redmineManager.GetObject <Role>(ROLE_ID, null);

            Assert.IsNotNull(role, "Get role returned null.");
            Assert.AreEqual(role.Name, ROLE_NAME, "Role name is invalid.");;
            Assert.IsNotNull(role.Permissions, "Role permisions list is null.");
            CollectionAssert.AllItemsAreNotNull(role.Permissions.ToList(), "Permissions contains null items.");
            CollectionAssert.AllItemsAreUnique(role.Permissions.ToList(), "Permissions are not unique.");
            Assert.IsTrue(role.Permissions.Count == NUMBER_OF_ROLE_PERMISSIONS, "Permissions count != " + NUMBER_OF_ROLE_PERMISSIONS);
        }
Beispiel #20
0
        public IEnumerable <CommonRemineEntities.Tracker> GetTrackers(int projectId)
        {
            var filter = new NameValueCollection
            {
                { RedmineKeys.INCLUDE, RedmineKeys.TRACKERS }
            };

            return(RedmineManager.GetObject <Project>(projectId.ToString(), filter).Trackers
                   .Select(t => EntityMapper.Map <CommonRemineEntities.Tracker>(t))
                   .ToArray());
        }
Beispiel #21
0
        public void RedmineUser_ShouldGetUserById()
        {
            var id = 8;

            User user = redmineManager.GetObject <User>(id.ToString(), new NameValueCollection {
                { "include", "groups" }, { "include", "memberships" }
            });

            Assert.AreEqual(user.Login, "alinac");
        }
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (!ParentCB.IsChecked.Value && !ExistCB.IsChecked.Value)
     {
         MessageBox.Show("Выберите что-то хотите проанализировать!");
     }
     else
     {
         accessToken = accessTokenRM.Text;
         parameters  = new NameValueCollection {
             { RedmineKeys.INCLUDE, RedmineKeys.CHILDREN }
         };
         try
         {
             RedmineManager manager = new RedmineManager("https://redmine.minsvyazdnr.ru", accessToken);
             if (manager.GetObject <Issue>(redmineIssue.Text, parameters) != null)
             {
                 Issue        issue             = manager.GetObject <Issue>(redmineIssue.Text, parameters);
                 string       description       = issue.Description;
                 HtmlDocument parsedDescription = new HtmlDocument();
                 parsedDescription.LoadHtml(description);
                 HtmlNodeCollection childs = parsedDescription.DocumentNode.ChildNodes;
                 TreeNode <string>  treeRM = new TreeNode <string>("root");
                 BuildRedmineTree(ref issue, ref treeRM, ref manager);
                 TreeNode <string> treeDashboard = new TreeNode <string>("root");
                 BuildDashboardTree(ref childs, ref treeDashboard);
                 IssueList.Items.Clear();
                 CompareTrees(treeRM, treeDashboard);
             }
             else
             {
                 MessageBox.Show("Задача не найдена!");
             }
         }
         catch (Exception exp)
         {
             MessageBox.Show("Возникла непредвиденная ошибка!\n" + exp);
         }
     }
 }
        public void RedmineIssueCategory_ShouldGetIssueCategoryById()
        {
            IssueCategory issueCategory = redmineManager.GetObject <IssueCategory>(issueCategoryIdToGet, null);

            Assert.IsNotNull(issueCategory);
            Assert.IsTrue(issueCategory.AsignTo.Name.Contains(issueCategoryAsigneeNameToGet));
        }
Beispiel #24
0
        private void redmineButton_Click(object sender, EventArgs e)
        {
            // うごかない

            var rm    = new RedmineManager(conf.redmineUrl, conf.redmineApiKey);
            var param = new NameValueCollection {
                { "status_id", "*" }
            };

            var issue = rm.GetObject <Issue>("18481", param);

            RedmineTextBox.Text = issue.ToString();
        }
Beispiel #25
0
        public void Should_Get_IssueCategory_By_Id()
        {
            IssueCategory issueCategory = redmineManager.GetObject <IssueCategory>(ISSUE_CATEGORY_ID_TO_GET, null);

            Assert.IsNotNull(issueCategory, "Get issue category returned null.");
            Assert.AreEqual(issueCategory.Name, ISSUE_CATEGORY_NAME_TO_GET, "Issue category name is invalid.");
            Assert.IsNotNull(issueCategory.AsignTo, "Issue category asignee is null.");
            Assert.IsTrue(issueCategory.AsignTo.Name.Contains(ISSUE_CATEGORY_ASIGNEE_NAME_TO_GET), "Asignee name is invalid.");
            Assert.IsNotNull(issueCategory.Project, "Issue category project is null.");
            Assert.IsTrue(issueCategory.Project.Name.Equals(ISSUE_CATEGORY_PROJECT_NAME_TO_GET), "Project name is invalid.");
        }
Beispiel #26
0
        public void Should_Get_Time_Entry_By_Id()
        {
            var timeEntry = redmineManager.GetObject <TimeEntry>(TIME_ENTRY_ID, null);

            Assert.IsNotNull(timeEntry, "Get object returned null.");
            Assert.IsInstanceOfType(timeEntry, typeof(TimeEntry), "Returned object is not of type TimeEntry.");
            Assert.IsNotNull(timeEntry.Project, "Project is null.");
            Assert.IsNotNull(timeEntry.SpentOn, "Spent on date is null.");
            Assert.IsNotNull(timeEntry.Hours, "Hours is null.");
            Assert.IsNotNull(timeEntry.Activity, "Activity is null.");
        }
        public void Should_Get_Project_Membership_By_Id()
        {
            var projectMembership = redmineManager.GetObject <ProjectMembership>(PROJECT_MEMBERSHIP_ID, null);

            Assert.IsNotNull(projectMembership, "Get project membership returned null.");
            Assert.IsNotNull(projectMembership.Project, "Project is null.");
            Assert.IsTrue(projectMembership.User != null || projectMembership.Group != null, "User and group are both null.");
            Assert.IsNotNull(projectMembership.Roles, "Project membership roles list is null.");
            CollectionAssert.AllItemsAreNotNull(projectMembership.Roles, "Project membership roles list contains null items.");
            CollectionAssert.AllItemsAreUnique(projectMembership.Roles, "Project membership roles items are not unique.");
            CollectionAssert.AllItemsAreInstancesOfType(projectMembership.Roles, typeof(MembershipRole), "Not all items are of type MembershipRole.");
        }
Beispiel #28
0
        public void RedmineUser_ShouldCompareUsers()
        {
            RedmineManager redmineSecondManager;

            #if JSON
            redmineSecondManager = new RedmineManager(uri, apiKey, MimeFormat.xml);
            #else
            redmineSecondManager = new RedmineManager(uri, apiKey, MimeFormat.json);
            #endif

            User user = redmineManager.GetObject <User>(userId, new NameValueCollection {
                { "include", "groups,memberships" }
            });
            User secondUser = redmineSecondManager.GetObject <User>(userId, new NameValueCollection {
                { "include", "groups,memberships" }
            });

            Assert.IsTrue(user.Equals(secondUser));
        }
 private void BuildRedmineTree(ref Issue rootIssue, ref TreeNode <string> tree, ref RedmineManager manager)
 {
     if (rootIssue.Children != null)
     {
         foreach (var child in rootIssue.Children)
         {
             tree.AddChild(child.Id.ToString());
             try
             {
                 var childI = manager.GetObject <Issue>(child.Id.ToString(), parameters);
                 var leaf   = tree.FindTreeNode(x => x.ToString() == child.Id.ToString());
                 if (childI.Children != null)
                 {
                     BuildRedmineTree(ref childI, ref leaf, ref manager);
                 }
             }
             catch (Redmine.Net.Api.Exceptions.ForbiddenException exp) { }
         }
     }
 }
Beispiel #30
0
        public static IEnumerable <Issue> GetIssues(string redmineHost,
                                                    string redmineApiKey,
                                                    IEnumerable <long> issueIds)
        {
            var redmineManager = new RedmineManager(redmineHost,
                                                    redmineApiKey,
                                                    MimeFormat.json);
            var result = issueIds.AsParallel() // we are doing a .AsParallel here, as the Redmine API is very slow :confused:
                         .Select(arg =>
            {
                var issueId = arg.ToString();
                var issue   = redmineManager.GetObject <Issue>(issueId,
                                                               new NameValueCollection());

                return(issue);
            })
                         .ToArray();

            return(result);
        }
Beispiel #31
0
    public static IEnumerable<Issue> GetIssues(string redmineHost,
                                               string redmineApiKey,
                                               IEnumerable<long> issueIds)
    {
      var redmineManager = new RedmineManager(redmineHost,
                                              redmineApiKey,
                                              MimeFormat.json);
      var result = issueIds.AsParallel() // we are doing a .AsParallel here, as the Redmine API is very slow :confused:
                           .Select(arg =>
                                   {
                                     var issueId = arg.ToString();
                                     var issue = redmineManager.GetObject<Issue>(issueId,
                                                                                 new NameValueCollection());

                                     return issue;
                                   })
                           .ToArray();

      return result;
    }
        public void RedmineUser_ShouldCompareUsers()
        {
            RedmineManager redmineSecondManager;

            #if JSON
                redmineSecondManager = new RedmineManager(uri, apiKey, MimeFormat.xml);
            #else
                redmineSecondManager = new RedmineManager(uri, apiKey, MimeFormat.json);
            #endif

            User user = redmineManager.GetObject<User>(userId, new NameValueCollection { { "include", "groups,memberships" } });
            User secondUser = redmineSecondManager.GetObject<User>(userId, new NameValueCollection { { "include", "groups,memberships" } });

            Assert.IsTrue(user.Equals(secondUser));
        }