Esempio n. 1
0
        public async Task Should_Create_User()
        {
            User user = new User();

            user.Login                = "******";
            user.FirstName            = "userTestFirstName";
            user.LastName             = "userTestLastName";
            user.Email                = "*****@*****.**";
            user.Password             = "******";
            user.AuthenticationModeId = 1;
            user.MustChangePassword   = false;
            user.CustomFields         = new List <IssueCustomField>();
            user.CustomFields.Add(new IssueCustomField {
                Id = 4, Values = new List <CustomFieldValue> {
                    new CustomFieldValue {
                        Info = "userTestCustomField:" + DateTime.UtcNow
                    }
                }
            });

            var createdUser = await redmineManager.CreateObjectAsync(user);

            Assert.AreEqual(user.Login, createdUser.Login);
            Assert.AreEqual(user.Email, createdUser.Email);
        }
        public void Should_Add_Project_Membership()
        {
            ProjectMembership pm = new ProjectMembership();

            pm.User = new IdentifiableName {
                Id = USER_ID
            };
            pm.Roles = new List <MembershipRole>();
            pm.Roles.Add(new MembershipRole {
                Id = ROLE_ID
            });

            var updatedPM = redmineManager.CreateObjectAsync <ProjectMembership>(pm, PROJECT_ID);
            var delay     = Delay(3000);
            int index     = Task.WaitAny(updatedPM, delay);

            if (index == 0)
            {
                Assert.IsNotNull(updatedPM.Result, "Project membership is null.");
            }
            else
            {
                Assert.Fail("Operation timeout.");
            }
        }
        private async Task <TimeEntry> LogTime(TimeEntry entry)
        {
            // Avoid problems with issue names lookup if numerical Id is available
            if (entry.Issue.Id != 0)
            {
                entry.Issue.Name = null;
            }
            if (entry.Activity.Id != 0)
            {
                entry.Activity.Name = null;
            }

            var savedEntry = await _manager.CreateObjectAsync(entry);

            return(savedEntry);
        }
        public async Task Should_Add_Project_Membership()
        {
            ProjectMembership pm = new ProjectMembership();

            pm.User = new IdentifiableName {
                Id = newPMUserId
            };
            pm.Roles = new List <MembershipRole>();
            pm.Roles.Add(new MembershipRole {
                Id = newPMRoleId
            });

            ProjectMembership updatedPM = await redmineManager.CreateObjectAsync <ProjectMembership>(pm, projectId);

            Assert.IsNotNull(updatedPM);
        }
Esempio n. 5
0
        public async Task <CommonRemineEntities.Issue> CreateOrUpdateIssueAsync(CommonRemineEntities.Issue issue)
        {
            var redmineIssue = EntityMapper.Map <Issue>(issue);

            if (issue.Id.HasValue)
            {
                await RedmineManager.UpdateObjectAsync(redmineIssue.Id.ToString(), redmineIssue);

                return(issue);
            }
            else
            {
                var newRedmineIssue = await RedmineManager.CreateObjectAsync(redmineIssue);

                return(EntityMapper.Map <CommonRemineEntities.Issue>(newRedmineIssue));
            }
        }
Esempio n. 6
0
        public async Task Should_Upload_Attachment()
        {
            //read document from specified path
            string documentPath = "E:\\uploadAttachment.txt";

            byte[] documentData = File.ReadAllBytes(documentPath);

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

            //set attachment properties
            attachment.FileName    = "AttachmentUploaded.txt";
            attachment.Description = "File uploaded using REST API";
            attachment.ContentType = "text/plain";

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

            attachments.Add(attachment);

            //read document from specified path
            documentPath = "E:\\uploadAttachment1.txt";
            documentData = File.ReadAllBytes(documentPath);

            //upload attachment to redmine
            Upload attachment1 = await redmineManager.UploadFileAsync(documentData);

            //set attachment properties
            attachment1.FileName    = "AttachmentUploaded1.txt";
            attachment1.Description = "Second file uploaded";
            attachment1.ContentType = "text/plain";
            attachments.Add(attachment1);

            Issue issue = new Issue();

            issue.Project = new Project {
                Id = 10
            };
            issue.Tracker = new IdentifiableName {
                Id = 4
            };
            issue.Status = new IdentifiableName {
                Id = 5
            };
            issue.Priority = new IdentifiableName {
                Id = 8
            };
            issue.Subject     = "Issue with attachments";
            issue.Description = "Issue description...";
            issue.Category    = new IdentifiableName {
                Id = 11
            };
            issue.FixedVersion = new IdentifiableName {
                Id = 9
            };
            issue.AssignedTo = new IdentifiableName {
                Id = 8
            };
            issue.ParentIssue = new IdentifiableName {
                Id = 19
            };
            issue.CustomFields = new List <IssueCustomField>();
            issue.CustomFields.Add(new IssueCustomField {
                Id = 13, Values = new List <CustomFieldValue> {
                    new CustomFieldValue {
                        Info = "Issue custom field completed"
                    }
                }
            });
            issue.IsPrivate      = true;
            issue.EstimatedHours = 12;
            issue.StartDate      = DateTime.Now;
            issue.DueDate        = DateTime.Now.AddMonths(1);
            issue.Uploads        = attachments;
            issue.Watchers       = new List <Watcher>();
            issue.Watchers.Add(new Watcher {
                Id = 8
            });
            issue.Watchers.Add(new Watcher {
                Id = 2
            });

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

            issue = await redmineManager.GetObjectAsync <Issue>(issueWithAttachment.Id.ToString(), new NameValueCollection { { "include", "attachments" } });

            Assert.IsNotNull(issue, "Get issue returned null.");
            Assert.IsInstanceOfType(issue, typeof(Issue));

            Assert.IsTrue(issue.Attachments.Count == 2, "Attachments count != 2");
            CollectionAssert.AllItemsAreNotNull(issue.Attachments.ToList(), "Attachments contains null items.");
            CollectionAssert.AllItemsAreUnique(issue.Attachments.ToList(), "Attachments items are not unique.");
            Assert.IsTrue(issue.Attachments[0].FileName == attachment.FileName);
            Assert.IsTrue(issue.Attachments[1].FileName == attachment1.FileName);
        }