Esempio n. 1
0
        public void Should_Create_Version()
        {
            const string         NEW_VERSION_NAME        = "VersionTesting";
            const VersionStatus  NEW_VERSION_STATUS      = VersionStatus.Locked;
            const VersionSharing NEW_VERSION_SHARING     = VersionSharing.Hierarchy;
            DateTime             newVersionDueDate       = DateTime.Now.AddDays(7);
            const string         NEW_VERSION_DESCRIPTION = "Version description";

            var version = new Version
            {
                Name        = NEW_VERSION_NAME,
                Status      = NEW_VERSION_STATUS,
                Sharing     = NEW_VERSION_SHARING,
                DueDate     = newVersionDueDate,
                Description = NEW_VERSION_DESCRIPTION
            };

            var savedVersion = fixture.RedmineManager.CreateObject(version, PROJECT_ID);

            Assert.NotNull(savedVersion);
            Assert.NotNull(savedVersion.Project);
            Assert.True(savedVersion.Name.Equals(NEW_VERSION_NAME), "Version name is invalid.");
            Assert.True(savedVersion.Status.Equals(NEW_VERSION_STATUS), "Version status is invalid.");
            Assert.True(savedVersion.Sharing.Equals(NEW_VERSION_SHARING), "Version sharing is invalid.");
            Assert.NotNull(savedVersion.DueDate);
            Assert.True(savedVersion.DueDate.Value.Date.Equals(newVersionDueDate.Date), "Version due date is invalid.");
            Assert.True(savedVersion.Description.Equals(NEW_VERSION_DESCRIPTION), "Version description is invalid.");
        }
        public void RedmineProjectVersion_ShouldDeleteVersion()
        {
            var versionId = "12";

            try
            {
                redmineManager.DeleteObject <Redmine.Net.Api.Types.Version>(versionId, null);
            }
            catch (RedmineException)
            {
                Assert.Fail("Version could not be deleted.");
                return;
            }

            try
            {
                Redmine.Net.Api.Types.Version version = redmineManager.GetObject <Redmine.Net.Api.Types.Version>(versionId, null);
            }
            catch (RedmineException exc)
            {
                StringAssert.Contains(exc.Message, "Not Found");
                return;
            }
            Assert.Fail("Test failed");
        }
        public override object Deserialize(
            IDictionary <string, object> dictionary,
            Type type,
            JavaScriptSerializer serializer)
        {
            if (dictionary == null)
            {
                return(null);
            }
            var version = new Version
            {
                Id           = dictionary.GetValue <int>("id"),
                Description  = dictionary.GetValue <string>("description"),
                Name         = dictionary.GetValue <string>("name"),
                CreatedOn    = dictionary.GetValue <DateTime?>("created_on"),
                UpdatedOn    = dictionary.GetValue <DateTime?>("updated_on"),
                DueDate      = dictionary.GetValue <DateTime?>("due_date"),
                Project      = dictionary.GetValueAsIdentifiableName("project"),
                Sharing      = dictionary.GetValue <VersionSharing>("sharing"),
                Status       = dictionary.GetValue <VersionStatus>("status"),
                CustomFields =
                    dictionary.GetValueAsCollection <IssueCustomField>("custom_fields")
            };

            return(version);
        }
Esempio n. 4
0
        public void Should_Create_Version()
        {
            const string NEW_VERSION_NAME = "VersionTesting";
            const VersionStatus NEW_VERSION_STATUS = VersionStatus.locked;
            const VersionSharing NEW_VERSION_SHARING = VersionSharing.hierarchy;
            DateTime NEW_VERSION_DUE_DATE = DateTime.Now.AddDays(7);
            const string NEW_VERSION_DESCRIPTION = "Version description";

            var version = new Version
            {
                Name = NEW_VERSION_NAME,
                Status = NEW_VERSION_STATUS,
                Sharing = NEW_VERSION_SHARING,
                DueDate = NEW_VERSION_DUE_DATE,
                Description = NEW_VERSION_DESCRIPTION
            };

            var savedVersion = fixture.RedmineManager.CreateObject(version, PROJECT_ID);

            Assert.NotNull(savedVersion);
            Assert.NotNull(savedVersion.Project);
            Assert.True(savedVersion.Name.Equals(NEW_VERSION_NAME), "Version name is invalid.");
            Assert.True(savedVersion.Status.Equals(NEW_VERSION_STATUS), "Version status is invalid.");
            Assert.True(savedVersion.Sharing.Equals(NEW_VERSION_SHARING), "Version sharing is invalid.");
            Assert.NotNull(savedVersion.DueDate);
            Assert.True(savedVersion.DueDate.Value.Date.Equals(NEW_VERSION_DUE_DATE.Date), "Version due date is invalid.");
            Assert.True(savedVersion.Description.Equals(NEW_VERSION_DESCRIPTION), "Version description is invalid.");
        }
Esempio n. 5
0
        public void RedmineProjectVersion_ShouldCompare()
        {
            Redmine.Net.Api.Types.Version version          = redmineManager.GetObject <Redmine.Net.Api.Types.Version>(versionId, null);
            Redmine.Net.Api.Types.Version versionToCompare = redmineManager.GetObject <Redmine.Net.Api.Types.Version>(versionId, null);

            Assert.IsTrue(version.Equals(versionToCompare));
        }
        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);
        }
Esempio n. 7
0
        public void Should_Compare_Versions()
        {
            Redmine.Net.Api.Types.Version version          = redmineManager.GetObject <Redmine.Net.Api.Types.Version>(VERSION_ID, null);
            Redmine.Net.Api.Types.Version versionToCompare = redmineManager.GetObject <Redmine.Net.Api.Types.Version>(VERSION_ID, null);

            Assert.IsNotNull(version, "Version is null.");
            Assert.IsTrue(version.Equals(versionToCompare), "Versions are not equal.");
        }
Esempio n. 8
0
        public void RedmineProjectVersion_ShouldCreateNewVersion()
        {
            Redmine.Net.Api.Types.Version version = new Redmine.Net.Api.Types.Version();
            version.Name        = newVersionName;
            version.Status      = newVersionStatus;
            version.Sharing     = newVersionSharing;
            version.DueDate     = newVersionDueDate;
            version.Description = newVersionDescription;

            Redmine.Net.Api.Types.Version savedVersion = redmineManager.CreateObject <Redmine.Net.Api.Types.Version>(version, projectId);

            Assert.AreEqual(version.Name, savedVersion.Name);
        }
        public void RedmineProjectVersion_ShouldCreateNewVersion()
        {
            Redmine.Net.Api.Types.Version version = new Redmine.Net.Api.Types.Version();
            version.Name        = "Test version";
            version.Status      = VersionStatus.locked;
            version.Sharing     = VersionSharing.hierarchy;
            version.DueDate     = DateTime.Now.AddDays(7);
            version.Description = "Version description";

            Redmine.Net.Api.Types.Version savedVersion = redmineManager.CreateObject <Redmine.Net.Api.Types.Version>(version, "6");

            Assert.AreEqual(version.Name, savedVersion.Name);
        }
Esempio n. 10
0
        public void RedmineProjectVersion_ShouldCreateNewVersion()
        {
            Redmine.Net.Api.Types.Version version = new Redmine.Net.Api.Types.Version();
            version.Name = "Test version";
            version.Status = VersionStatus.locked;
            version.Sharing = VersionSharing.hierarchy;
            version.DueDate = DateTime.Now.AddDays(7);
            version.Description = "Version description";

            Redmine.Net.Api.Types.Version savedVersion = redmineManager.CreateObject<Redmine.Net.Api.Types.Version>(version, "6");

            Assert.AreEqual(version.Name, savedVersion.Name);
        }
Esempio n. 11
0
        public void RedmineProjectVersion_ShouldCreateNewVersion()
        {
            Redmine.Net.Api.Types.Version version = new Redmine.Net.Api.Types.Version();
            version.Name = newVersionName;
            version.Status = newVersionStatus;
            version.Sharing = newVersionSharing;
            version.DueDate = newVersionDueDate;
            version.Description = newVersionDescription;

            Redmine.Net.Api.Types.Version savedVersion = redmineManager.CreateObject<Redmine.Net.Api.Types.Version>(version, projectId);

            Assert.AreEqual(version.Name, savedVersion.Name);
        }
Esempio n. 12
0
        public void RedmineProjectVersion_ShouldUpdateVersion()
        {
            Redmine.Net.Api.Types.Version version = redmineManager.GetObject <Redmine.Net.Api.Types.Version>(updatedVersionId, null);
            version.Name        = updatedVersionName;
            version.Status      = updatedVersionStatus;
            version.Sharing     = updatedVersionSharing;
            version.DueDate     = updatedVersionDueDate;
            version.Description = updatedVersionDescription;

            redmineManager.UpdateObject <Redmine.Net.Api.Types.Version>(updatedVersionId, version);

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

            Assert.AreEqual(version.Name, updatedVersion.Name);
        }
Esempio n. 13
0
        public void Should_Update_Version()
        {
            Redmine.Net.Api.Types.Version version = redmineManager.GetObject <Redmine.Net.Api.Types.Version>(UPDATED_VERSION_ID, null);
            version.Name        = UPDATED_VERSION_NAME;
            version.Status      = UPDATED_VERSION_STATUS;
            version.Sharing     = UPDATED_VERSION_SHARING;
            version.DueDate     = UPDATED_VERSION_DUE_DATE;
            version.Description = UPDATED_VERSION_DESCRIPTION;

            redmineManager.UpdateObject <Redmine.Net.Api.Types.Version>(UPDATED_VERSION_ID, version);

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

            Assert.IsNotNull(updatedVersion, "Updated version is null.");
            Assert.AreEqual <Redmine.Net.Api.Types.Version>(version, updatedVersion, "Version was not properly updated.");
        }
        public void RedmineProjectVersion_ShouldUpdateVersion()
        {
            var versionId = "12";

            Redmine.Net.Api.Types.Version version = redmineManager.GetObject <Redmine.Net.Api.Types.Version>(versionId, null);
            version.Name        = "Updated version";
            version.Status      = VersionStatus.closed;
            version.Sharing     = VersionSharing.system;
            version.DueDate     = DateTime.Now.AddMonths(1);
            version.Description = "Updated description";

            redmineManager.UpdateObject <Redmine.Net.Api.Types.Version>(versionId, version);

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

            Assert.AreEqual(version.Name, updatedVersion.Name);
        }
Esempio n. 15
0
        public void Should_Create_Version()
        {
            Redmine.Net.Api.Types.Version version = new Redmine.Net.Api.Types.Version();
            version.Name        = NEW_VERSION_NAME;
            version.Status      = NEW_VERSION_STATUS;
            version.Sharing     = NEW_VERSION_SHARING;
            version.DueDate     = NEW_VERSION_DUE_DATE;
            version.Description = NEW_VERSION_DESCRIPTION;

            Redmine.Net.Api.Types.Version savedVersion = redmineManager.CreateObject <Redmine.Net.Api.Types.Version>(version, PROJECT_ID);

            Assert.IsNotNull(savedVersion, "Create version returned null.");
            Assert.IsNotNull(savedVersion.Project, "Project is null.");
            Assert.AreEqual(savedVersion.Name, NEW_VERSION_NAME, "Version name is invalid.");
            Assert.AreEqual(savedVersion.Status, NEW_VERSION_STATUS, "Version status is invalid.");
            Assert.AreEqual(savedVersion.Sharing, NEW_VERSION_SHARING, "Version sharing is invalid.");
            Assert.IsNotNull(savedVersion.DueDate, "Due date is null.");
            Assert.AreEqual(savedVersion.DueDate.Value.Date, NEW_VERSION_DUE_DATE.Date, "Version due date is invalid.");
            Assert.AreEqual(savedVersion.Description, NEW_VERSION_DESCRIPTION, "Version description is invalid.");
        }
Esempio n. 16
0
        public void Should_Create_Version()
        {
            Redmine.Net.Api.Types.Version version = new Redmine.Net.Api.Types.Version();
            version.Name = NEW_VERSION_NAME;
            version.Status = NEW_VERSION_STATUS;
            version.Sharing = NEW_VERSION_SHARING;
            version.DueDate = NEW_VERSION_DUE_DATE;
            version.Description = NEW_VERSION_DESCRIPTION;

            Redmine.Net.Api.Types.Version savedVersion = redmineManager.CreateObject<Redmine.Net.Api.Types.Version>(version, PROJECT_ID);

            Assert.IsNotNull(savedVersion, "Create version returned null.");
            Assert.IsNotNull(savedVersion.Project, "Project is null.");
            Assert.AreEqual(savedVersion.Name, NEW_VERSION_NAME, "Version name is invalid.");
            Assert.AreEqual(savedVersion.Status, NEW_VERSION_STATUS, "Version status is invalid.");
            Assert.AreEqual(savedVersion.Sharing, NEW_VERSION_SHARING, "Version sharing is invalid.");
            Assert.IsNotNull(savedVersion.DueDate, "Due date is null.");
            Assert.AreEqual(savedVersion.DueDate.Value.Date, NEW_VERSION_DUE_DATE.Date, "Version due date is invalid.");
            Assert.AreEqual(savedVersion.Description, NEW_VERSION_DESCRIPTION, "Version description is invalid.");
        }
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            if (dictionary != null)
            {
                var version = new Version();

                version.Id = dictionary.GetValue<int>("id");
                version.Description = dictionary.GetValue<string>("description");
                version.Name = dictionary.GetValue<string>("name");
                version.CreatedOn = dictionary.GetValue<DateTime?>("created_on");
                version.UpdatedOn = dictionary.GetValue<DateTime?>("updated_on");
                version.DueDate = dictionary.GetValue<DateTime?>("due_date");
                version.Project = dictionary.GetValueAsIdentifiableName("project");
                version.Sharing = dictionary.GetValue<VersionSharing>("sharing");
                version.Status = dictionary.GetValue<VersionStatus>("status");
                version.CustomFields = dictionary.GetValueAsCollection<IssueCustomField>("custom_fields");

                return version;
            }

            return null;
        }
Esempio n. 18
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            if (dictionary != null)
            {
                var version = new Version();

                version.Id           = dictionary.GetValue <int>(RedmineKeys.ID);
                version.Description  = dictionary.GetValue <string>(RedmineKeys.DESCRIPTION);
                version.Name         = dictionary.GetValue <string>(RedmineKeys.NAME);
                version.CreatedOn    = dictionary.GetValue <DateTime?>(RedmineKeys.CREATED_ON);
                version.UpdatedOn    = dictionary.GetValue <DateTime?>(RedmineKeys.UPDATED_ON);
                version.DueDate      = dictionary.GetValue <DateTime?>(RedmineKeys.DUE_DATE);
                version.Project      = dictionary.GetValueAsIdentifiableName(RedmineKeys.PROJECT);
                version.Sharing      = dictionary.GetValue <VersionSharing>(RedmineKeys.SHARING);
                version.Status       = dictionary.GetValue <VersionStatus>(RedmineKeys.STATUS);
                version.CustomFields = dictionary.GetValueAsCollection <IssueCustomField>(RedmineKeys.CUSTOM_FIELDS);

                return(version);
            }

            return(null);
        }
Esempio n. 19
0
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            if (dictionary != null)
            {
                var version = new Version();

                version.Id = dictionary.GetValue<int>(RedmineKeys.ID);
                version.Description = dictionary.GetValue<string>(RedmineKeys.DESCRIPTION);
                version.Name = dictionary.GetValue<string>(RedmineKeys.NAME);
                version.CreatedOn = dictionary.GetValue<DateTime?>(RedmineKeys.CREATED_ON);
                version.UpdatedOn = dictionary.GetValue<DateTime?>(RedmineKeys.UPDATED_ON);
                version.DueDate = dictionary.GetValue<DateTime?>(RedmineKeys.DUE_DATE);
                version.Project = dictionary.GetValueAsIdentifiableName(RedmineKeys.PROJECT);
                version.Sharing = dictionary.GetValue<VersionSharing>(RedmineKeys.SHARING);
                version.Status = dictionary.GetValue<VersionStatus>(RedmineKeys.STATUS);
                version.CustomFields = dictionary.GetValueAsCollection<IssueCustomField>(RedmineKeys.CUSTOM_FIELDS);

                return version;
            }

            return null;
        }
Esempio n. 20
0
        public void Should_Delete_Version()
        {
            try
            {
                redmineManager.DeleteObject <Redmine.Net.Api.Types.Version>(DELETED_VERSION_ID, null);
            }
            catch (RedmineException)
            {
                Assert.Fail("Version could not be deleted.");
                return;
            }

            try
            {
                Redmine.Net.Api.Types.Version version = redmineManager.GetObject <Redmine.Net.Api.Types.Version>(DELETED_VERSION_ID, null);
            }
            catch (RedmineException exc)
            {
                StringAssert.Contains(exc.Message, "Not Found");
                return;
            }
            Assert.Fail("Test failed");
        }
Esempio n. 21
0
        public void Should_Get_Version_By_Id()
        {
            Redmine.Net.Api.Types.Version version = redmineManager.GetObject <Redmine.Net.Api.Types.Version>(VERSION_ID, null);

            Assert.IsNotNull(version, "Get version returned null.");
        }
Esempio n. 22
0
        public static Task GetChangesFromRedmine()
        {
            return(Task.Run(() =>
            {
                var parameters = new NameValueCollection {
                    { "include", "relations" }
                };
                var redProject = rm.GetObject <Project>("50", parameters);
                var versions = rm.GetObjectList <Redmine.Net.Api.Types.Version>(new NameValueCollection
                {
                    { "include", "relations" },
                    { "project_id", redProject.Id.ToString() }
                }).ToList();

                versions = versions.Where(v => v.DueDate > DateTime.Now.Subtract(TimeSpan.FromDays(1))).OrderBy(v => v.DueDate).ToList();

                Redmine.Net.Api.Types.Version selectedVersion = null;
                Application.Current.Dispatcher.Invoke(() =>
                {
                    var pickVersion = new SelectVersion(versions);
                    pickVersion.Owner = MainWindow.Instance;
                    pickVersion.ShowDialog();

                    selectedVersion = pickVersion.Version;
                    RedmineVersion = pickVersion.Version.Name;
                });

                rm.PageSize = 9998;
                int offset = 0;
                issues = rejectedIssues = designTickets = new List <Issue>();
                var issues_ =
                    rm.GetObjectList <Issue>(new NameValueCollection
                {
                    { "include", "relations" },
                    { "status_id", "5" },
                    { "project_id", redProject.Id.ToString() },
                    { "fixed_version_id", selectedVersion.Id.ToString() }
                });

                while (issues_.Count > 0)
                {
                    issues = issues.Concat(issues_).ToList();
                    offset += 25;
                    issues_ =
                        rm.GetObjectList <Issue>(new NameValueCollection
                    {
                        { "include", "relations" },
                        { "status_id", "5" },
                        { "offset", offset.ToString() },
                        { "project_id", redProject.Id.ToString() },
                        { "fixed_version_id", selectedVersion.Id.ToString() }
                    });
                }
                if (issues.Any(i => i.Tracker.Id == 4))
                {
                    designTickets = issues.Where(i => i.Tracker.Id == 4).ToList();
                    issues = issues.Where(i => i.Tracker.Id != 4).ToList();
                }

                //rejected
                offset = 0;
                _rejectedIssues = new List <Issue>();
                issues_ =
                    rm.GetObjectList <Issue>(new NameValueCollection
                {
                    { "include", "relations,journals" },
                    { "status_id", "6" },
                    { "project_id", redProject.Id.ToString() },
                    { "fixed_version_id", selectedVersion.Id.ToString() }
                });

                while (issues_.Count > 0)
                {
                    rejectedIssues = rejectedIssues.Concat(issues_).ToList();
                    offset += 25;
                    issues_ =
                        rm.GetObjectList <Issue>(new NameValueCollection
                    {
                        { "include", "relations,journals" },
                        { "status_id", "6" },
                        { "offset", offset.ToString() },
                        { "project_id", redProject.Id.ToString() },
                        { "fixed_version_id", selectedVersion.Id.ToString() }
                    });
                }

                var issuesWithoutSupport = issues;
                _supportIssuesCount = 0;
                issues = new List <Issue>();
                foreach (var iss in issuesWithoutSupport)
                {
                    if (iss.Tracker != null && iss.Tracker.Id != 3)
                    {
                        issues.Add(iss);
                    }
                    else
                    {
                        _supportIssuesCount++;
                    }
                }
            }));
        }