Beispiel #1
0
        public void Release_Constructor()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-VSTeamRelease.json");

            // Act
            var target = new Release(obj[0], ps, "Project Name");

            // Assert
            Assert.AreEqual(259, target.Id, "Id");
            Assert.AreEqual("active", target.Status, "Status");
            Assert.AreEqual(259, target.ReleaseId, "ReleaseId");
            Assert.IsNotNull(target.Environments, "Environments");
            Assert.AreEqual("2", target.DefinitionId, "DefinitionId");
            Assert.AreEqual(0, target.Environments.Count, "Environments.Count");
            Assert.AreEqual("PTracker-CD", target.DefinitionName, "DefinitionName");
            Assert.AreEqual("00000000-0000-0000-0000-000000000000", target.ProjectId, "ProjectId");

            Assert.IsNotNull(target.Variables, "Variables");
            Assert.IsNotNull(target.ReleaseDefinition, "ReleaseDefinition");

            Assert.AreEqual("*****@*****.**", target.ModifiedBy.UniqueName, "ModifiedBy.UniqueName");
            Assert.AreEqual("Donovan Brown", target.CreatedBy.DisplayName, "CreatedBy.DisplayName");
            Assert.AreEqual("11/14/2019 12:56:09 am", target.CreatedOn.ToString("M/d/yyyy h:mm:ss tt").ToLower(), "CreatedOn.ToString()");

            Assert.AreEqual("Donovan Brown", target.CreatedByUser, "CreatedByUser");
            Assert.AreEqual("Donovan Brown", target.ModifiedByUser, "ModifiedByUser");
        }
Beispiel #2
0
        public void Feed_Constructor()
        {
            // Arrange
            var obj = BaseTests.LoadJson("Get-VSTeamFeed.json");

            // Act
            var actual = new Feed(obj[0]);

            // Assert
            Assert.AreEqual("ber", actual.Name, "Name");
            Assert.AreEqual(null, actual.Description, "Description");
            Assert.AreEqual(true, actual.UpstreamEnabled, "UpstreamEnaabled");
            Assert.AreEqual("00000000-0000-0000-0000-000000000001", actual.Id, "Id");
            Assert.AreEqual("00000000-0000-0000-0000-000000000001", actual.FeedId, "FeedId");
            Assert.AreEqual("https://feeds.dev.azure.com/Test/_apis/Packaging/Feeds/00000000-0000-0000-0000-000000000000", actual.Url, "Url");

            Assert.IsNotNull(actual.UpstreamSources, "UpstreamSources");
            Assert.AreEqual(4, actual.UpstreamSources.Count, "UpstreamSources.Count");

            Assert.AreEqual("npmjs", actual.UpstreamSources[0].Name, "Name");
            Assert.AreEqual("ok", actual.UpstreamSources[0].Status, "Status");
            Assert.AreEqual("npm", actual.UpstreamSources[0].Protocol, "Protocol");
            Assert.IsNotNull(actual.UpstreamSources[0].InternalObject, "InternalObject");
            Assert.AreEqual("00000000-0000-0000-0000-000000000010", actual.UpstreamSources[0].ID);
            Assert.AreEqual("public", actual.UpstreamSources[0].UpstreamSourceType, "UpstreamSourceType");
            Assert.AreEqual("https://registry.npmjs.org/", actual.UpstreamSources[0].Location, "Location");
            Assert.AreEqual("https://registry.npmjs.org/", actual.UpstreamSources[0].DisplayLocation, "DisplayLocation");
        }
Beispiel #3
0
        public void Group_Constructor()
        {
            // Arrange
            var obj = BaseTests.LoadJson("Get-VSTeamGroup.json");

            // Act
            var target = new Group(obj[0]);

            // Assert
            Assert.AreEqual("vsts", target.Origin, "Origin");
            Assert.AreEqual(null, target.MailAddress, "MailAddress");
            Assert.IsNotNull(target.InternalObject, "InternalObject");
            Assert.AreEqual("Test", target.ProjectName, "ProjectName");
            Assert.AreEqual("group", target.SubjectKind, "SubjectKind");
            Assert.AreEqual("redacted", target.Descriptor, "Descriptor");
            Assert.AreEqual("redacted", target.ContainerDescriptor, "ContainerDescriptor");
            Assert.AreEqual("00000000-0000-0000-0000-000000000000", target.OriginId, "OriginId");
            Assert.AreEqual("Project Collection Build Administrators", target.DisplayName, "DisplayName");
            Assert.AreEqual("https://vssps.dev.azure.com/Test/_apis/Graph/Groups/redacted", target.Url, "Url");
            Assert.AreEqual("[Test]\\Project Collection Build Administrators", target.PrincipalName, "PrincipalName");
            Assert.AreEqual("vstfs:///Framework/IdentityDomain/00000000-0000-0000-0000-000000000000", target.Domain, "Domain");
            Assert.AreEqual("Members of this group should include accounts for people who should be able to administer the build resources.", target.Description, "Description");



            Assert.IsNotNull(target.Links, "Links");
            Assert.IsNotNull(target.Links.InternalObject, "Links.InternalObject");
            Assert.AreEqual("https://vssps.dev.azure.com/Test/_apis/Graph/Groups/redacted", target.Links.Self, "Links.Self");
            Assert.AreEqual("https://vssps.dev.azure.com/Test/_apis/Graph/Memberships/redacted", target.Links.Memberships, "Links.Memberships");
            Assert.AreEqual("https://vssps.dev.azure.com/Test/_apis/Graph/MembershipStates/redacted", target.Links.MembershipState, "Links.MembershipState");
            Assert.AreEqual("https://vssps.dev.azure.com/Test/_apis/Graph/StorageKeys/redacted", target.Links.StorageKey, "Links.StorageKey");
        }
        public void SecurityNamespaceTests_Constructor()
        {
            // Arrange
            var obj = BaseTests.LoadJson("Get-VSTeamSecurityNamespace.json");

            // Act
            var target = new SecurityNamespace(obj[0]);

            // Assert
            Assert.AreEqual("Analytics", target.Name, "Name");
            Assert.IsNull(target.ExtensionType, "ExtensionType");
            Assert.AreEqual(false, target.IsRemotable, "IsRemotable");
            Assert.AreEqual(30, target.SystemBitMask, "SystemBitMask");
            Assert.AreEqual(-1, target.ElementLength, "ElementLength");
            Assert.AreEqual(1, target.ReadPermission, "ReadPermission");
            Assert.AreEqual("/", target.SeparatorValue, "SeparatorValue");
            Assert.AreEqual("1", target.StructureValue, "StructureValue");
            Assert.AreEqual(2, target.WritePermission, "WritePermission");
            Assert.AreEqual("Analytics", target.DisplayName, "DisplayName");
            Assert.AreEqual(false, target.UseTokenTranslator, "UseTokenTranslator");
            Assert.AreEqual("Default", target.DataspaceCategory, "DataspaceCategory");

            Assert.AreEqual("Analytics", target.ToString(), "ToString()");

            Assert.IsNotNull(target.Actions, "Actions");
            Assert.AreEqual(5, target.Actions.Count, "Actions.Count");
            Assert.AreEqual(1, target.Actions[0].Bit, "Actions[0].Bit");
            Assert.AreEqual("Read", target.Actions[0].Name, "Actions[0].Name");
            Assert.AreEqual(Guid.Empty, target.Actions[0].NamespaceId, "Actions[0].NamespaceId");
            Assert.AreEqual("View analytics", target.Actions[0].DisplayName, "Actions[0].DisplayName");
        }
Beispiel #5
0
        public void User_Constructor_With_MetaType()
        {
            // Arrange
            var obj = BaseTests.LoadJson("Get-VSTeamUser.json");

            // Act
            var target = new User(obj[3]);

            // Assert
            Assert.AreEqual("aad", target.Origin, "Origin");
            Assert.AreEqual("member", target.MetaType, "MetaType");
            Assert.AreEqual(null, target.ProjectName, "ProjectName");
            Assert.IsNotNull(target.InternalObject, "InternalObject");
            Assert.AreEqual("user", target.SubjectKind, "SubjectKind");
            Assert.AreEqual("Redacted", target.Descriptor, "Descriptor");
            Assert.AreEqual("Donovan Brown", target.DisplayName, "DisplayName");
            Assert.AreEqual("Redacted", target.MemberDescriptor, "MemberDescriptor");
            Assert.AreEqual("*****@*****.**", target.MailAddress, "MailAddress");
            Assert.AreEqual("*****@*****.**", target.PrincipalName, "PrincipalName");
            Assert.AreEqual("00000000-0000-0000-0000-000000000088", target.Domain, "Domain");
            Assert.AreEqual("00000000-0000-0000-0000-000000000008", target.OriginId, "OriginId");
            Assert.AreEqual("https://vssps.dev.azure.com/Test/_apis/Graph/Users/Redacted", target.Url, "Url");

            Assert.IsNotNull(target.Links, "Links");
            Assert.IsNotNull(target.Links.InternalObject, "Links.InternalObject");
            Assert.AreEqual("https://vssps.dev.azure.com/Test/_apis/Graph/Users/Redacted", target.Links.Self, "Links.Self");
            Assert.AreEqual("https://vssps.dev.azure.com/Test/_apis/Graph/Memberships/Redacted", target.Links.Memberships, "Links.Memberships");
            Assert.AreEqual("https://vssps.dev.azure.com/Test/_apis/Graph/MembershipStates/Redacted", target.Links.MembershipState, "Links.MembershipState");
            Assert.AreEqual("https://vssps.dev.azure.com/Test/_apis/Graph/StorageKeys/Redacted", target.Links.StorageKey, "Links.StorageKey");
            Assert.AreEqual("https://dev.azure.com/Test/_apis/GraphProfile/MemberAvatars/Redacted", target.Links.Avatar, "Links.Avatar");
        }
Beispiel #6
0
        public void BuildDefinition_Constructor_2017_Git()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-BuildDefinition_2017.json");

            // Act
            var actual = new BuildDefinition(obj[0], "Project Name", ps);

            // Assert
            Assert.IsNull(actual.Tags, "Tags");
            Assert.IsNull(actual.Demands, "Demands");

            Assert.IsNotNull(actual.Queue, "Queue");
            Assert.IsNotNull(actual.Variables, "Variables");
            Assert.IsNotNull(actual.AuthoredBy, "AuthoredBy");
            Assert.IsNotNull(actual.Repository, "Repository");
            Assert.IsNotNull(actual.GitRepository, "GitRepository");
            Assert.IsNotNull(actual.RetentionRules, "RetentionRules");

            Assert.AreEqual("BuildDefinition", actual.ResourceType, "ResourceType");

            Assert.AreEqual(5, actual.JobCancelTimeoutInMinutes, "JobCancelTimeoutInMinutes");
            Assert.AreEqual("projectCollection", actual.JobAuthorizationScope, "JobAuthorizationScope");
            Assert.AreEqual("$(date:yyyyMMdd)$(rev:.r)", actual.BuildNumberFormat, "BuildNumberFormat");

            Assert.AreEqual("8/23/2020 3:12:41 pm", actual.CreatedOn.ToString("M/d/yyyy h:mm:ss tt").ToLower(), "CreatedOn");

            Assert.IsNotNull(actual.Options, "Options");
            Assert.AreEqual(4, actual.Options.Count, "Options.Count");

            Assert.IsNull(actual.Triggers, "Triggers");

            Assert.AreEqual(17, actual.Id, "Id");
            Assert.AreEqual("CI", actual.Name, "Name");
            Assert.AreEqual("\\", actual.Path, "Path");
            Assert.AreEqual(1, actual.Revision, "Revision");

            Assert.AreEqual("CI", actual.ToString(), "ToString()");

            Assert.IsNull(actual.Process, "Process");

            Assert.IsNotNull(actual.Steps, "Steps");
            Assert.AreEqual(5, actual.Steps.Count, "Steps.Count");

            // Testing BuildDefinitionProcessPhaseStep properties
            Assert.IsNotNull(actual.Steps[0].Task, "Steps[0].Task");
            Assert.IsNotNull(actual.Steps[0].Inputs, "Steps[0].Inputs");
            Assert.AreEqual(true, actual.Steps[0].Enabled, "Steps[0].Enabled");
            Assert.AreEqual(null, actual.Steps[0].Condition, "Steps[0].Condition");
            Assert.AreEqual(false, actual.Steps[0].AlwaysRun, "Steps[0].AlwaysRun");
            Assert.AreEqual("NuGet restore", actual.Steps[0].Name, "Steps[0].Name");
            Assert.AreEqual(0, actual.Steps[0].TimeoutInMinutes, "Steps[0].TimeoutInMinutes");
            Assert.AreEqual(false, actual.Steps[0].ContinueOnError, "Steps[0].ContinueOnError");
        }
Beispiel #7
0
        public void JobRequest_Constructor_Queued()
        {
            // Arrange
            var jobRequests = BaseTests.LoadJson("Get-VSTeamJobRequest-PoolId1-AgentID111.json");

            // Act
            var target = new JobRequest(jobRequests[1]);

            // Assert
            Assert.AreEqual("queued", target.Result, "Result");
        }
Beispiel #8
0
        public void Team_Constructor()
        {
            // Arrange
            var obj = BaseTests.LoadJson("Get-VSTeam.json");

            // Act
            var actual = new Team(obj[0], "ProjectName");

            // Assert
            Assert.AreEqual("The default project team.", actual.Description, "Description");
        }
Beispiel #9
0
        public void GitRef_Constructor()
        {
            // Arrange
            var obj = BaseTests.LoadJson("Get-VSTeamGitRef.json");

            // Act
            var actual = new GitRef(obj[0], "TestProject");

            // Assert
            Assert.IsNotNull(actual.Creator, "Creator");
            Assert.AreEqual("refs/heads/master", actual.RefName, "RefName");
        }
Beispiel #10
0
        public void BuildDefinition_GetChildItem_2018()
        {
            // Arrange
            var ps     = BaseTests.PrepPowerShell();
            var obj    = BaseTests.LoadJson("Get-BuildDefinition_2018.json");
            var target = new BuildDefinition(obj[0], "Project Name", ps);

            // Act
            var actual = target.GetChildItem();

            // Assert
            Assert.IsNotNull(actual, "actual");
        }
Beispiel #11
0
        public void Queue_Constructor()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-VSTeamQueue.json");

            // Act
            var target = new Queue(obj[0], "Project Name", ps);

            // Assert
            Assert.IsNotNull(target.Pool, "Pool");
            Assert.AreEqual("81", target.Id, "ID");
            Assert.AreEqual("DefaultPool", target.PoolName, "PoolName");
        }
Beispiel #12
0
        public void AccessControlList_Constructor()
        {
            // Arrange
            var obj = BaseTests.LoadJson("Get-VSTeamAccessControlList.json");

            // Act
            var target = new AccessControlList(obj[0]);

            // Assert
            Assert.AreEqual(1, target.Aces.Count, "Aces");
            Assert.AreEqual(true, target.InheritPermissions, "InheritPermissions");
            Assert.AreEqual("$/00000000-0000-0000-0000-000000000001", target.Token, "Token");
            Assert.AreEqual("$/00000000-0000-0000-0000-000000000001", target.ToString(), "ToString()");
        }
        public void BuildDefinitionProcessPhase_GetChildren()
        {
            // Arrange
            var ps       = BaseTests.PrepPowerShell();
            var obj      = BaseTests.LoadJson("Get-BuildDefinition_AzD.json");
            var buildDef = new BuildDefinition(obj[0], "Project Name", ps);
            var target   = (PSObject)buildDef.GetChildItem()[0];

            // Act
            var actual = ((BuildDefinitionProcessPhase)target.ImmediateBaseObject).GetChildItem();

            // Assert
            Assert.AreEqual(4, actual.Length);
        }
Beispiel #14
0
        public void Environment_GetChildItem()
        {
            // Arrange
            var ps     = BaseTests.PrepPowerShell();
            var obj    = BaseTests.LoadJson("Get-VSTeamRelease-id178-expandEnvironments.json", false);
            var envs   = obj[0].GetValue <object[]>("environments");
            var target = new Environment((PSObject)envs[0], 178, "projectName", ps);

            // Act
            var children = target.GetChildItem();

            // Assert
            Assert.AreEqual(1, children.Length);
        }
Beispiel #15
0
        public void BuildDefinition_GetChildItem_AzD_YAML()
        {
            // Arrange
            var ps     = BaseTests.PrepPowerShell();
            var obj    = BaseTests.LoadJson("Get-BuildDefinition_AzD.json");
            var target = new BuildDefinition(obj[7], "Project Name", ps);

            // Act
            var actual = target.GetChildItem();

            // Assert
            Assert.IsNotNull(actual, "actual");
            Assert.AreEqual(1, actual.Length, "actual.Length");
        }
Beispiel #16
0
        public void UserEntitlementTests_Constructor_ById()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-VSTeamUserEntitlement-Id.json", false);

            // Act
            var target = new UserEntitlement(obj[0]);

            // Assert
            Assert.AreEqual("*****@*****.**", target.Email, "Email");
            Assert.AreEqual("Donovan Brown", target.UserName, "UserName");
            Assert.AreEqual("Early Adopter", target.AccessLevelName, "AccessLevelName");
        }
Beispiel #17
0
        public void BuildDefinition_Constructor_2018()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-BuildDefinition_2018.json");

            // Act
            var actual = new BuildDefinition(obj[0], "Project Name", ps);

            // Assert
            Assert.IsNotNull(actual.Tags, "Tags");
            Assert.AreEqual(0, actual.Tags.Count, "Tags.Count");

            Assert.IsNull(actual.Demands, "Demands");

            Assert.IsNotNull(actual.Queue, "Queue");
            Assert.IsNotNull(actual.Variables, "Variables");
            Assert.IsNotNull(actual.AuthoredBy, "AuthoredBy");
            Assert.IsNotNull(actual.Repository, "Repository");
            Assert.IsNotNull(actual.GitRepository, "GitRepository");
            Assert.IsNotNull(actual.RetentionRules, "RetentionRules");

            Assert.AreEqual("8/23/2020 3:16:22 pm", actual.CreatedOn.ToString("M/d/yyyy h:mm:ss tt").ToLower(), "CreatedOn");

            Assert.AreEqual(5, actual.JobCancelTimeoutInMinutes, "JobCancelTimeoutInMinutes");
            Assert.AreEqual("projectCollection", actual.JobAuthorizationScope, "JobAuthorizationScope");
            Assert.AreEqual("$(date:yyyyMMdd)$(rev:.r)", actual.BuildNumberFormat, "BuildNumberFormat");

            Assert.IsNotNull(actual.Options, "Options");
            Assert.AreEqual(2, actual.Options.Count, "Options.Count");

            Assert.IsNull(actual.Triggers, "Triggers");

            Assert.AreEqual(27, actual.Id, "Id");
            Assert.AreEqual("CI", actual.Name, "Name");
            Assert.AreEqual("\\", actual.Path, "Path");
            Assert.AreEqual(1, actual.Revision, "Revision");

            Assert.IsNotNull(actual.Process, "Process");
            Assert.AreEqual(1, actual.Process.Phases.Count, "Process.Steps.Count");
            Assert.AreEqual("Number of phases: 1", actual.Process.ToString(), "Process.ToString()");

            Assert.IsNotNull(actual.Process.Phases[0].Steps, "Process.Phases[0].Steps");
            Assert.IsNotNull(actual.Process.Phases[0].Target, "Process.Phases[0].Target");
            Assert.AreEqual(6, actual.Process.Phases[0].StepCount, "Process.Phases[0].StepsCount");
            Assert.AreEqual(6, actual.Process.Phases[0].Steps.Count, "Process.Phases[0].Steps.Count");
            Assert.AreEqual("succeeded()", actual.Process.Phases[0].Condition, "Process.Phases[0].Condition");
            Assert.AreEqual(1, actual.Process.Phases[0].JobCancelTimeoutInMinutes, "Process.Phases[0].JobCancelTimeoutInMinutes");
            Assert.AreEqual("projectCollection", actual.Process.Phases[0].JobAuthorizationScope, "Process.Phases[0].JobAuthorizationScope");
        }
Beispiel #18
0
        public void AgentPool_Constructor_Hosted()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-VSTeamPool.json");

            // Act
            var target = new AgentPool(obj[1], ps);

            // Assert
            Assert.AreEqual(2, target.Id, "Id");
            Assert.AreEqual(15, target.Count, "Count");
            Assert.AreEqual(true, target.IsHosted, "IsHosted");
            Assert.AreEqual("d-r-s-", target.DisplayMode, "DisplayMode");
        }
Beispiel #19
0
        public void Environment_Constructor()
        {
            // Arrange
            var ps   = BaseTests.PrepPowerShell();
            var obj  = BaseTests.LoadJson("Get-VSTeamRelease-id178-expandEnvironments.json", false);
            var envs = obj[0].GetValue <object[]>("environments");

            // Act
            var target = new Environment((PSObject)envs[0], 178, "projectName", ps);

            // Assert
            Assert.AreEqual(2149, target.Id, "Id");
            Assert.AreEqual(178, target.ReleaseId, "ReleaseId");
            Assert.AreEqual("succeeded", target.Status, "Status");
            Assert.AreEqual(2149, target.EnvironmentId, "EnvironmentId");
        }
Beispiel #20
0
        public void Releases_GetChildItem()
        {
            // Arrange
            var ps       = BaseTests.PrepPowerShell();
            var target   = new Releases(ps, "Project Name");
            var obj      = BaseTests.LoadJson("Get-VSTeamRelease.json");
            var releases = new Collection <PSObject>(obj.Select(o => PSObject.AsPSObject(o)).ToList());

            ps.Invoke().Returns(releases);

            // Act
            var children = target.GetChildItem();

            // Assert
            Assert.AreEqual(2, children.Length, "Length");
        }
Beispiel #21
0
        public void Release_GetChildItem()
        {
            // Arrange
            var ps           = BaseTests.PrepPowerShell();
            var obj          = BaseTests.LoadJson("Get-VSTeamRelease-id178-expandEnvironments.json", false);
            var target       = new Release(obj[0], ps, "Project Name");
            var envs         = obj[0].GetValue <object[]>("environments");
            var environments = new Collection <PSObject>(envs.Select(e => PSObject.AsPSObject(e)).ToList());

            ps.Invoke().Returns(environments);

            // Act
            var children = target.GetChildItem();

            // Assert
            Assert.AreEqual(19, children.Length);
        }
Beispiel #22
0
        public void GitRepository_GetChildItem()
        {
            // Arrange
            var ps      = BaseTests.PrepPowerShell();
            var gitRefs = BaseTests.LoadJson("Get-VSTeamGitRef.json");
            var obj     = BaseTests.LoadJson("Get-VSTeamGitRepository.json");
            var target  = new GitRepository(obj[0], "Project Name", ps);

            ps.Invoke().Returns(gitRefs);

            // Act
            var actual = target.GetChildItem();

            // Assert
            Assert.AreEqual(1, actual.Length);
            ps.Received().AddCommand("Get-VSTeamGitRef");
        }
        public void ClassificationNodeTests_Constructor_ById()
        {
            // Arrange
            var obj = BaseTests.LoadJson("Get-VSTeamClassificationNode-depth3-ids82.json");

            // Act
            var target = new ClassificationNode(obj[0], "Project Name");

            // Assert
            Assert.IsNull(target.ParentUrl, "ParentUrl");
            Assert.IsNotNull(target.Children, "Children");
            Assert.AreEqual(true, target.HasChildren, "HasChildren");
            Assert.AreEqual(Guid.Empty, target.Identifier, "Identifier");
            Assert.AreEqual("\\PeopleTracker\\Iteration", target.Path, "Path");
            Assert.AreEqual("iteration", target.StructureType, "StructureType");
            Assert.AreEqual("https://dev.azure.com/Test/00000000-0000-0000-0000-000000000000/_apis/wit/classificationNodes/Iterations", target.Url, "Url");
        }
Beispiel #24
0
        public void DescriptorTests_Constructor()
        {
            // Arrange
            var obj           = BaseTests.LoadJson("descriptor.scope.TestProject.json", false);
            var n             = System.Environment.NewLine;
            var expectedLinks = $"Self: https://vssps.dev.azure.com/test/_apis/Graph/Descriptors/010d06f0-00d5-472a-bb47-58947c230876{n}StorageKey: https://vssps.dev.azure.com/test/_apis/Graph/StorageKeys/scp.ZGU5ODYwOWEtZjRiMC00YWEzLTgzOTEtODI4ZDU2MDI0MjU2{n}Subject: https://vssps.dev.azure.com/test/_apis/Graph/Scopes/scp.ZGU5ODYwOWEtZjRiMC00YWEzLTgzOTEtODI4ZDU2MDI0MjU2{n}";

            // Act
            var target = new Descriptor(obj[0]);

            // Assert
            Assert.IsNotNull(target.Links, "Links");
            Assert.AreEqual(expectedLinks, target.Links.ToString(), "ToString");
            Assert.AreEqual("scp.ZGU5ODYwOWEtZjRiMC00YWEzLTgzOTEtODI4ZDU2MDI0MjU2", target.Name, "Name");
            Assert.AreEqual("scp.ZGU5ODYwOWEtZjRiMC00YWEzLTgzOTEtODI4ZDU2MDI0MjU2", target.ToString(), "ToString");
            Assert.AreEqual("https://vssps.dev.azure.com/test/_apis/Graph/Scopes/scp.ZGU5ODYwOWEtZjRiMC00YWEzLTgzOTEtODI4ZDU2MDI0MjU2", target.Links.Subject, "Links.Subject");
        }
Beispiel #25
0
        public void AgentPool_GetChildItem()
        {
            // Arrange
            var ps     = BaseTests.PrepPowerShell();
            var pools  = BaseTests.LoadJson("Get-VSTeamPool.json");
            var agents = BaseTests.LoadJson("Get-VSTeamAgent-PoolId1.json");

            ps.Invoke().Returns(agents);

            var target = new AgentPool(pools[0], ps);

            // Act
            var actual = target.GetChildItem();

            // Assert
            Assert.AreEqual(4, actual.Length);
            ps.Received().AddCommand("Get-VSTeamAgent");
        }
Beispiel #26
0
        public void Agent_GetChildItem()
        {
            // Arrange
            var ps          = BaseTests.PrepPowerShell();
            var agents      = BaseTests.LoadJson("Get-VSTeamPool.json");
            var jobRequests = BaseTests.LoadJson("Get-VSTeamJobRequest-PoolId1-AgentID111.json");

            ps.Invoke().Returns(jobRequests);

            var target = new Agent(agents[0], 1, ps);

            // Act
            var actual = target.GetChildItem();

            // Assert
            Assert.AreEqual(3, actual.Length);
            ps.Received().AddCommand("Get-VSTeamJobRequest");
        }
Beispiel #27
0
        public void Build_Constructor()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-VSTeamBuild.json");

            // Act
            var actual = new Build(obj[0], "Project Name", ps);

            // Assert
            Assert.AreEqual("81", actual.QueueId, "QueueId");
            Assert.IsNotNull(actual.RequestedBy, "RequestedBy");
            Assert.IsNotNull(actual.RequestedFor, "RequestedFor");
            Assert.AreEqual("completed", actual.Status, "Status");
            Assert.AreEqual("succeeded", actual.Result, "Result");
            Assert.IsNotNull(actual.LastChangedBy, "LastChangedBy");
            Assert.AreEqual("568", actual.BuildNumber, "BuildNumber");
            Assert.AreEqual("Default", actual.QueueName, "QueueName");
            Assert.AreEqual("TfsGit", actual.RepositoryType, "RepositoryType");
            Assert.AreEqual("PTracker-CI", actual.DefinitionName, "DefinitionName");
            Assert.AreEqual("Donovan Brown", actual.RequestedByUser, "RequestedByUser");
            Assert.AreEqual("Donovan Brown", actual.RequestedForUser, "RequestedForUser");
            Assert.AreEqual("11/14/2019 12:49:37 am", actual.StartTime?.ToString("M/d/yyyy h:mm:ss tt").ToLower(), "startTime");
            Assert.AreEqual("Microsoft.VisualStudio.Services.ReleaseManagement", actual.LastChangedByUser, "LastChangedByUser");

            Assert.IsNotNull(actual.TriggerInfo, "TriggerInfo");

            Assert.IsNotNull(actual.Queue, "Queue");
            Assert.IsNotNull(actual.Queue.Pool, "Queue.Pool");
            Assert.AreEqual("81", actual.Queue.Id, "Queue.Id");
            Assert.AreEqual("Default", actual.Queue.PoolName, "Queue.PoolName");

            Assert.IsNotNull(actual.BuildDefinition, "BuildDefinition");
            Assert.AreEqual(23, actual.BuildDefinition.Id, "BuildDefinition.Id");
            Assert.AreEqual("PTracker-CI", actual.BuildDefinition.Name, "BuildDefinition.Name");

            Assert.IsNotNull(actual.Project, "Project");
            Assert.AreEqual("PeopleTracker", actual.Project.Name, "Project.Name");
            Assert.AreEqual("00000000-0000-0000-0000-000000000000", actual.Project.Id, "Project.Id");

            Assert.AreEqual("*****@*****.**", actual.RequestedBy.UniqueName, "RequestedBy.UniqueName");
            Assert.AreEqual("Donovan Brown", actual.RequestedFor.DisplayName, "RequestedFor.DisplayName");
            Assert.AreEqual("Microsoft.VisualStudio.Services.ReleaseManagement", actual.LastChangedBy.ToString(), "LastChangedBy.ToString()");
        }
Beispiel #28
0
        public void BuildDefinition_Constructor_AzD_Classic()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-BuildDefinition_AzD.json");

            // Act
            var actual = new BuildDefinition(obj[0], "Project Name", ps);

            // Assert
            Assert.IsNotNull(actual.Tags, "Tags");
            Assert.AreEqual(0, actual.Tags.Count, "Tags.Count");

            Assert.IsNull(actual.Demands, "Demands");

            Assert.AreEqual("9/16/2019 2:34:16 am", actual.CreatedOn.ToString("M/d/yyyy h:mm:ss tt").ToLower(), "CreatedOn");

            // Not on this build def
            Assert.AreEqual(null, actual.BuildNumberFormat, "BuildNumberFormat");
            Assert.AreEqual(5, actual.JobCancelTimeoutInMinutes, "JobCancelTimeoutInMinutes");
            Assert.AreEqual("projectCollection", actual.JobAuthorizationScope, "JobAuthorizationScope");

            Assert.IsNotNull(actual.Queue, "Queue");
            Assert.IsNotNull(actual.Variables, "Variables");
            Assert.IsNotNull(actual.AuthoredBy, "AuthoredBy");
            Assert.IsNotNull(actual.Repository, "Repository");
            Assert.IsNotNull(actual.GitRepository, "GitRepository");
            Assert.IsNotNull(actual.RetentionRules, "RetentionRules");

            Assert.IsNotNull(actual.Options, "Options");
            Assert.AreEqual(2, actual.Options.Count, "Options.Count");

            Assert.IsNotNull(actual.Triggers, "Triggers");
            Assert.AreEqual(1, actual.Triggers.Count, "Triggers.Count");

            Assert.AreEqual(23, actual.Id, "Id");
            Assert.AreEqual("\\", actual.Path, "Path");
            Assert.AreEqual("PTracker-CI", actual.Name, "Name");
            Assert.AreEqual(163, actual.Revision, "Revision");

            Assert.IsNotNull(actual.Process, "Process");
            Assert.IsNotNull(actual.Process.Phases, "Process.Phases");
        }
Beispiel #29
0
        public void BuildDefinition_Constructor_AzD_YAML()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-BuildDefinition_AzD.json");

            // Act
            var actual = new BuildDefinition(obj[7], "Project Name", ps);

            // Assert
            Assert.IsNotNull(actual.Tags, "Tags");
            Assert.AreEqual(2, actual.Tags.Count, "Tags.Count");

            Assert.IsNull(actual.Demands, "Demands");

            Assert.AreEqual("9/25/2019 8:55:54 pm", actual.CreatedOn.ToString("M/d/yyyy h:mm:ss tt").ToLower(), "CreatedOn");

            // Not on this build def
            Assert.AreEqual(0, actual.JobCancelTimeoutInMinutes, "JobCancelTimeoutInMinutes");
            Assert.AreEqual("projectCollection", actual.JobAuthorizationScope, "JobAuthorizationScope");
            Assert.AreEqual("$(date:yyyyMMdd)$(rev:.r)", actual.BuildNumberFormat, "BuildNumberFormat");

            Assert.IsNotNull(actual.Queue, "Queue");
            Assert.IsNotNull(actual.Variables, "Variables");
            Assert.IsNotNull(actual.AuthoredBy, "AuthoredBy");
            Assert.IsNotNull(actual.Repository, "Repository");
            Assert.IsNull(actual.RetentionRules, "RetentionRules");
            Assert.IsNotNull(actual.GitRepository, "GitRepository");

            Assert.IsNull(actual.Options, "Options");

            Assert.IsNotNull(actual.Triggers, "Triggers");
            Assert.AreEqual(1, actual.Triggers.Count, "Triggers.Count");

            Assert.AreEqual(46, actual.Id, "Id");
            Assert.AreEqual("\\Vars", actual.Path, "Path");
            Assert.AreEqual("Vars CI", actual.Name, "Name");
            Assert.AreEqual(1, actual.Revision, "Revision");

            Assert.IsNotNull(actual.Process, "Process");
            Assert.IsNull(actual.Process.Phases, "Process.Phases");
            Assert.AreEqual("/azure-pipelines.yml", actual.Process.ToString(), "Process.ToString()");
        }
Beispiel #30
0
        public void Agent_Constructor()
        {
            // Arrange
            var ps     = BaseTests.PrepPowerShell();
            var agents = BaseTests.LoadJson("Get-VSTeamAgent-PoolId1.json");

            // Act
            var target = new Agent(agents[0], 1, ps);

            // Assert
            Assert.IsNotNull(target.SystemCapabilities);
            Assert.AreEqual(1, target.PoolId, "PoolId");
            Assert.AreEqual(111, target.AgentId, "AgentId");
            Assert.AreEqual(true, target.Enabled, "Enabled");
            Assert.AreEqual("offline", target.Status, "Status");
            Assert.AreEqual("2.155.1", target.Version, "Version");
            Assert.AreEqual("WinBldBox-3_Service2", target.Name, "Name");
            Assert.AreEqual("Microsoft Windows 6.3.9600 ", target.OS, "OS");
        }