Ejemplo n.º 1
0
 public UserOptions()
 {
     BranchTags = new List<BranchTagInfo>();
     BranchLinks = new BranchLinkInfoList();
     UserCredentials = new Credentials();
 }
        public void GetBranchViewTest()
        {
            var testModules = new GitModuleInfoList
            {
                new GitModuleInfo
                {
                    Caption = "Main",
                    SubmodulePath = "Main",
                    ProjectCaption = "Main",
                    Branches = new List<GitBranchInfo>
                               {
                                   new GitBranchInfo{Name = "feature/AA-12345-some-aa-branch", Type=BranchType.Local},
                                   new GitBranchInfo{Name = "feature/AA-12345-some-aa-branch", Type=BranchType.Remote},
                                   new GitBranchInfo{Name = "bug/AA-22222-some-bug-branch", Type=BranchType.Local},
                                   new GitBranchInfo{Name = "bug/AA-22222-some-bug-branch", Type=BranchType.Remote},
                               }
                },
                new GitModuleInfo
                {
                    Caption = "submodule/somelogic",
                    SubmodulePath = "submodule/somelogic",
                    ProjectCaption = "Main",
                    Branches = new List<GitBranchInfo>
                               {
                                   new GitBranchInfo{Name = "feature/AA-12345-some-aa-branch", Type=BranchType.Remote},
                                   new GitBranchInfo{Name = "bug/AA-22222-some-bug-branch", Type=BranchType.Remote, Merged = true},
                                   new GitBranchInfo{Name = "bug/AB-12345-some-another-bug-branch", Type=BranchType.Local},
                                   new GitBranchInfo{Name = "bug/AB-12345-some-another-bug-branch", Type=BranchType.Remote},
                               }
                },
                new GitModuleInfo
                {
                    Caption = "submodule/someactions",
                    SubmodulePath = "submodule/someactions",
                    ProjectCaption = "Main",
                    Branches = new List<GitBranchInfo>
                               {
                                   new GitBranchInfo{Name = "feature/AA-12345-some-aa-branch", Type=BranchType.Local},
                                   new GitBranchInfo{Name = "bug/AA-22222-some-bug-branch", Type=BranchType.Local},
                                   new GitBranchInfo{Name = "bug/AB-12345-some-another-bug-branch", Type=BranchType.Local},
                                   new GitBranchInfo{Name = "bug/AB-12345-some-another-bug-branch", Type=BranchType.Remote, Merged = true},
                               }
                },
                new GitModuleInfo
                {
                    Caption = "submodule/nobranches",
                    SubmodulePath = "submodule/nobranches",
                    ProjectCaption = "Main",
                    Branches = new List<GitBranchInfo>()
                }
            };
            var tags = new List<BranchTagInfo>
            {
                new BranchTagInfo{Tag = "ZZ-11111"},
                new BranchTagInfo{Tag = "AA-12345"},
                new BranchTagInfo{Tag = "bug-branch"}
            };
            var branchLinks = new BranchLinkInfoList
            {
                new BranchLinkInfo { BranchName = "feature/AA-12345-some-aa-branch", ParentBranchName = "release/release_01"}
            };

            var branchViews = testModules.GetBranchViews(tags, branchLinks);
            Assert.AreEqual(4, branchViews.Count);

            Assert.AreEqual("ZZ-11111", branchViews[0].Tag);
            Assert.AreEqual("", branchViews[0].Branch);
            Assert.AreEqual("", branchViews[0].ParentBranch);

            Assert.AreEqual("AA-12345", branchViews[1].Tag);
            Assert.AreEqual("feature/AA-12345-some-aa-branch", branchViews[1].Branch);
            Assert.AreEqual("", branchViews[1].ModulesMerged);
            Assert.AreEqual("Main; somelogic", branchViews[1].ModulesNotMerged);
            Assert.AreEqual(@"Main\someactions", branchViews[1].ModulesLocalOnly);
            Assert.AreEqual("release/release_01", branchViews[1].ParentBranch);
            Assert.AreEqual("feature/AA-12345-some-aa-branch => release/release_01", branchViews[1].BranchWithParent);

            Assert.AreEqual("bug-branch", branchViews[2].Tag);
            Assert.AreEqual("bug/AA-22222-some-bug-branch", branchViews[2].Branch);
            Assert.AreEqual("somelogic", branchViews[2].ModulesMerged);
            Assert.AreEqual("Main", branchViews[2].ModulesNotMerged);
            Assert.AreEqual(@"Main\someactions", branchViews[2].ModulesLocalOnly);
            Assert.AreEqual("master", branchViews[2].ParentBranch);
            Assert.AreEqual("bug/AA-22222-some-bug-branch", branchViews[2].BranchWithParent);

            Assert.AreEqual("bug-branch", branchViews[3].Tag);
            Assert.AreEqual("bug/AB-12345-some-another-bug-branch", branchViews[3].Branch);
            Assert.AreEqual("someactions", branchViews[3].ModulesMerged);
            Assert.AreEqual("somelogic", branchViews[3].ModulesNotMerged);
            Assert.AreEqual("", branchViews[3].ModulesLocalOnly);
            Assert.AreEqual("master", branchViews[3].ParentBranch);
            Assert.AreEqual("bug/AB-12345-some-another-bug-branch", branchViews[3].BranchWithParent);
        }