Exemplo n.º 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");
        }
Exemplo n.º 2
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");
        }
Exemplo n.º 3
0
        public void Directory_Get_VSTeam()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            // Act
            var target = new Directory("Teams", "Team", ps);

            // Assert
            Assert.AreEqual("Get-VSTeam", target.Command);
        }
Exemplo n.º 4
0
        public void Releases_Constructor()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            // Act
            var target = new Releases(ps, "Project Name");

            // Assert
            Assert.AreEqual("vsteam_lib.Provider.Release", target.TypeName, "TypeName");
        }
Exemplo n.º 5
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");
        }
Exemplo n.º 6
0
        public void Permissions_GetChildItem()
        {
            // Arrange
            var ps     = BaseTests.PrepPowerShell();
            var target = new Permissions("Permissions", ps);

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

            // Assert
            Assert.AreEqual(2, actual.Length);
            Assert.AreEqual("Groups", ((Directory)actual[0]).Name);
            Assert.AreEqual("Users", ((Directory)actual[1]).Name);
        }
Exemplo n.º 7
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);
        }
        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);
        }
Exemplo n.º 9
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");
        }
Exemplo n.º 10
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");
        }
Exemplo n.º 11
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");
        }
Exemplo n.º 12
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");
        }
Exemplo n.º 13
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");
        }
Exemplo n.º 14
0
        public void Account_Get_ChildItem_Should_Return_Permissions()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke().Returns(new Collection <PSObject>());
            var target = new Account("Accounts", ps);

            Versions.Graph = "6.0-preview";

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

            // Assert
            Assert.AreEqual(4, actual.Length);
        }
Exemplo n.º 15
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");
        }
Exemplo n.º 16
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");
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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");
        }
Exemplo n.º 19
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");
        }
Exemplo n.º 20
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");
        }
Exemplo n.º 21
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()");
        }
Exemplo n.º 22
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()");
        }
Exemplo n.º 23
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");
        }
Exemplo n.º 24
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");
        }
Exemplo n.º 25
0
        public void Directory_Has_ProjectName()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-VSTeamPool.json");

            ps.Invoke().Returns(obj);

            var target = new Directory(null, "Agent Pools", "Pool", ps, "MyProject");

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

            // Assert
            Assert.AreEqual(12, actual.Length);
            ps.Received().AddCommand("Sort-Object");
            ps.Received().AddCommand("Get-VSTeamPool");
            ps.Received().AddParameter("ProjectName", "MyProject");
        }
Exemplo n.º 26
0
        public void UserEntitlementTests_Constructor()
        {
            // Arrange
            var ps      = BaseTests.PrepPowerShell();
            var obj     = BaseTests.LoadJson("Get-VSTeamUserEntitlement.json", false);
            var members = obj[0].GetValue <object[]>("members");

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

            // Assert
            Assert.AreEqual("*****@*****.**", target.Email, "Email");
            Assert.AreEqual("Math lastName", target.UserName, "UserName");
            Assert.AreEqual("Math lastName", target.ToString(), "ToString()");
            Assert.AreEqual("Math lastName", target.DisplayName, "DisplayName");
            Assert.AreEqual("*****@*****.**", target.UniqueName, "UniqueName");
            Assert.AreEqual("Early Adopter", target.AccessLevelName, "AccessLevelName");
            Assert.AreEqual("9/9/2020 6:43:29 am", target.LastAccessedDate.ToString("M/d/yyyy h:mm:ss tt").ToLower(), "LastAccessedDate");
        }
Exemplo n.º 27
0
        public void Package_Constructor()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-VSTeamPackage.json");

            // Act
            var actual = new Package(obj[2], "MyFeed", ps);

            // Assert
            Assert.AreEqual("VSTeam", actual.Name, "Name");
            Assert.AreEqual("MyFeed", actual.FeedId, "FeedId");
            Assert.AreEqual("NuGet", actual.ProtocolType, "ProtocolType");
            Assert.AreEqual("vsteam", actual.NormalizedName, "NormalizedName");
            Assert.AreEqual(Guid.Parse("6c163345-4ec5-0000-84a9-2693e6f066d0"), actual.Id, "Id");
            Assert.AreEqual("https://feeds.dev.azure.com/Test/_apis/Packaging/Feeds/76045f1e-5b7c-0000-9ea5-df04e6b6c3f3/Packages/6c163345-4ec5-0000-84a9-2693e6f066d0", actual.Url, "Url");

            Assert.IsNotNull(actual.Links, "Links");
            Assert.IsNotNull(actual.Versions, "versions");
        }
Exemplo n.º 28
0
        public void Project_GetChildItem()
        {
            // Arrange
            var ps     = BaseTests.PrepPowerShell();
            var obj    = BaseTests.LoadJson("Get-VSTeamProject.json");
            var target = new Project(obj[0], ps);

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

            // Assert
            Assert.AreEqual(7, actual.Length);
            Assert.AreEqual("Build Definitions", ((Directory)actual[0]).Name);
            Assert.AreEqual("Builds", ((Directory)actual[1]).Name);
            Assert.AreEqual("Queues", ((Directory)actual[2]).Name);
            Assert.AreEqual("Release Definitions", ((Directory)actual[3]).Name);
            Assert.AreEqual("Releases", ((Releases)actual[4]).Name);
            Assert.AreEqual("Repositories", ((Directory)actual[5]).Name);
            Assert.AreEqual("Teams", ((Directory)actual[6]).Name);
        }
Exemplo n.º 29
0
        public void Build_Constructor_ById()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-VSTeamBuild-Id.json", false);

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

            // Assert
            Assert.IsNull(actual.Queue, "Queue");
            Assert.AreEqual(null, actual.QueueId, "QueueId");
            Assert.AreEqual(null, actual.QueueName, "QueueName");

            Assert.AreEqual(null, actual.Result, "Result");
            Assert.IsNotNull(actual.RequestedBy, "RequestedBy");
            Assert.IsNotNull(actual.RequestedFor, "RequestedFor");
            Assert.AreEqual("inProgress", actual.Status, "Status");
            Assert.IsNotNull(actual.LastChangedBy, "LastChangedBy");
            Assert.AreEqual("2272", actual.BuildNumber, "BuildNumber");
            Assert.AreEqual("GitHub", actual.RepositoryType, "RepositoryType");
            Assert.AreEqual("Team Module-CI (1)", actual.DefinitionName, "DefinitionName");
            Assert.AreEqual("Donovan Brown", actual.RequestedByUser, "RequestedByUser");
            Assert.AreEqual("Donovan Brown", actual.RequestedForUser, "RequestedForUser");
            Assert.AreEqual("9/23/2020 3:44:45 pm", actual.StartTime?.ToString("M/d/yyyy h:mm:ss tt").ToLower(), "startTime");
            Assert.AreEqual("Microsoft.VisualStudio.Services.TFS", actual.LastChangedByUser, "LastChangedByUser");

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

            Assert.IsNotNull(actual.BuildDefinition, "BuildDefinition");
            Assert.AreEqual(65, actual.BuildDefinition.Id, "BuildDefinition.Id");
            Assert.AreEqual("Team Module-CI (1)", actual.BuildDefinition.Name, "BuildDefinition.Name");

            Assert.IsNotNull(actual.Project, "Project");
            Assert.AreEqual("Team Module", 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.TFS", actual.LastChangedBy.ToString(), "LastChangedBy.ToString()");
        }
Exemplo n.º 30
0
        public void Project_Constructor()
        {
            // Arrange
            var ps  = BaseTests.PrepPowerShell();
            var obj = BaseTests.LoadJson("Get-VSTeamProject.json");

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

            // Assert
            Assert.AreEqual(159, target.Revision, "Revision");
            Assert.AreEqual("Voting-App", target.Name, "Name");
            Assert.AreEqual("wellFormed", target.State, "State");
            Assert.IsNotNull(target.InternalObject, "InternalObject");
            Assert.AreEqual("private", target.Visibility, "Visibility");
            Assert.AreEqual("Voting-App", target.ToString(), "ToString()");
            Assert.AreEqual("Vote App", target.Description, "Description");
            Assert.AreEqual("Voting-App", target.ProjectName, "ProjectName");
            Assert.AreEqual("00000000-0000-0000-0000-000000000001", target.Id, "Id");
            Assert.AreEqual("https://dev.azure.com/Test/_apis/projects/00000000-0000-0000-0000-000000000001", target.Url, "Url");
        }