Exemplo n.º 1
0
        public void TwoProjectsParentTest()
        {
            var projectA = new Project
            {
                GroupId    = "group",
                ArtifactId = "a",
                Version    = "1.0.0-SNAPSHOT".ToVersion()
            };

            var projectB = new Project
            {
                GroupId    = "group",
                ArtifactId = "b",
                Version    = "1.0.1-SNAPSHOT".ToVersion(),
                Parent     = new ParentReference
                {
                    GroupId    = "group",
                    ArtifactId = "a",
                    Version    = "1.0.0-SNAPSHOT".ToVersion()
                },
            };

            var repo = new Mock <IProjectsRepository>();

            repo.SetupGet(r => r.AllProjects).Returns(new IProject[] { projectA, projectB });

            var action = new BulkSwitchToReleaseAction(repo.Object, null, "-test");

            action.Execute();

            Assert.That(projectB.Parent.Version, Is.EqualTo(new ComponentVersion("1.0.0-test")));
        }
Exemplo n.º 2
0
        public void EmptyTest()
        {
            var repo   = new Mock <IProjectsRepository>();
            var action = new BulkSwitchToReleaseAction(repo.Object, null, "test");

            action.Execute();
        }
Exemplo n.º 3
0
        // TODO: DryRun?

        public void Execute()
        {
            var version = ComponentVersion.Undefined;

            if (!String.IsNullOrEmpty(VersionString))
            {
                Console.WriteLine("Release for all SNAPSHOT projects in folder {0} to release version {1}", Path, VersionString);
                version = new ComponentVersion(VersionString);
            }
            else
            {
                Console.WriteLine("Release for all SNAPSHOT projects in folder {0} with build {1} and \"{2}\" suffix", Path, Build, Suffix);
            }

            var solutionManagement = new SolutionManagement(GetActionLog());
            var solution           = solutionManagement.OpenSolution(Path, LoadAllProjects);

            Debug.WriteLine(solution.AllProjects.Count() + " projects loaded");

            BulkSwitchToReleaseAction action = version.IsDefined ?
                                               new BulkSwitchToReleaseAction(solution, version) :
                                               new BulkSwitchToReleaseAction(solution, Build, Suffix);

            action.Execute();

            solution.ForceSaveAll();
        }
Exemplo n.º 4
0
        public void SingleProjectToReleaseStrictTest()
        {
            var project = new Project
            {
                GroupId    = "group",
                ArtifactId = "a",
                Version    = "1.0.0-SNAPSHOT".ToVersion()
            };

            var repo = new Mock <IProjectsRepository>();

            repo.SetupGet(r => r.AllProjects).Returns(new IProject[] { project });

            var action = new BulkSwitchToReleaseAction(repo.Object, "0.1.0.123".ToVersion());

            Assert.Throws <InvalidOperationException>(delegate { action.Execute(); });
        }
Exemplo n.º 5
0
        public void ThreeProjectsCascadeGrouplessParentTest()
        {
            var projectA = new Project
            {
                GroupId    = "group",
                ArtifactId = "a",
                Version    = "1.0.0-SNAPSHOT".ToVersion()
            };

            var projectB = new Project
            {
                ArtifactId = "b",
                Parent     = new ParentReference
                {
                    GroupId    = "group",
                    ArtifactId = "a",
                    Version    = "1.0.0-SNAPSHOT".ToVersion()
                },
            };

            var projectC = new Project
            {
                ArtifactId = "c",
                Parent     = new ParentReference
                {
                    GroupId    = "group",
                    ArtifactId = "b",
                    Version    = "1.0.0-SNAPSHOT".ToVersion()
                },
            };

            var repo = new Mock <IProjectsRepository>();

            repo.SetupGet(r => r.AllProjects).Returns(new IProject[] { projectA, projectB, projectC });

            var action = new BulkSwitchToReleaseAction(repo.Object, null, "-test");

            action.Execute();

            Assert.That(projectB.Parent.Version, Is.EqualTo(new ComponentVersion("1.0.0-test")));
            Assert.That(projectB.Version.IsDefined, Is.False);

            Assert.That(projectC.Parent.Version, Is.EqualTo(new ComponentVersion("1.0.0-test")), "cascade parent version");
            Assert.That(projectC.Version.IsDefined, Is.False);
        }
Exemplo n.º 6
0
        public void SingleProjectToReleaseTest()
        {
            var project = new Project
            {
                GroupId    = "group",
                ArtifactId = "a",
                Version    = "1.0.0-SNAPSHOT".ToVersion()
            };

            var repo = new Mock <IProjectsRepository>();

            repo.SetupGet(r => r.AllProjects).Returns(new IProject[] { project });

            var action = new BulkSwitchToReleaseAction(repo.Object, "1.0.0.123".ToVersion());

            action.Execute();

            Assert.That(project.Version.Value, Is.EqualTo("1.0.0.123"));
        }
Exemplo n.º 7
0
        public void ExternalReferenceTest()
        {
            var projectA = new Project
            {
                GroupId    = "group",
                ArtifactId = "a",
                Version    = "1.0.0-SNAPSHOT".ToVersion()
            };

            var projectB = new Project
            {
                GroupId    = "group",
                ArtifactId = "b",
                Version    = "1.0.1-SNAPSHOT".ToVersion(),

                Parent = new ParentReference
                {
                    GroupId    = "group",
                    ArtifactId = "x",
                    Version    = "1.0.0-SNAPSHOT".ToVersion()
                },
            };

            projectB.Plugins.Add(
                new Plugin
            {
                GroupId    = "group",
                ArtifactId = "a",
                Version    = "1.0.0-SNAPSHOT".ToVersion()
            }
                );

            var repo = new Mock <IProjectsRepository>();

            repo.SetupGet(r => r.AllProjects).Returns(new IProject[] { projectA, projectB });

            var action = new BulkSwitchToReleaseAction(repo.Object, null, "-test");

            action.Execute();

            Assert.That(projectB.Parent.Version.Value, Is.EqualTo("1.0.0-SNAPSHOT"));
            // REVIEW: should we fail, when switch to release and parent is snapshot?
        }
Exemplo n.º 8
0
        public void TwoProjectsPluginTest()
        {
            var projectA = new Project
            {
                GroupId    = "group",
                ArtifactId = "a",
                Version    = "1.0.0-SNAPSHOT".ToVersion()
            };

            var projectB = new Project
            {
                GroupId    = "group",
                ArtifactId = "b",
                Version    = "1.0.1-SNAPSHOT".ToVersion()
            };

            projectB.Plugins.Add(
                new Plugin
            {
                GroupId    = "group",
                ArtifactId = "a",
                Version    = "1.0.0-SNAPSHOT".ToVersion()
            }
                );

            var repo = new Mock <IProjectsRepository>();

            repo.SetupGet(r => r.AllProjects).Returns(new IProject[] { projectA, projectB });

            var action = new BulkSwitchToReleaseAction(repo.Object, null, "-test");

            action.Execute();

            var plugin = projectB.Plugins.Single();

            Assert.That(plugin.Version.Value, Is.EqualTo("1.0.0-test"));
        }