public void TrackingConfig_ctor_should_fill_in_fields_correctly()
        {
            using (TestHostContext tc = Setup(out Mock <IExecutionContext> mockExecutionContext))
            {
                // Arrange.
                var repository = new RepositoryResource()
                {
                    Type = RepositoryTypes.Git, Url = new Uri(RepositoryUrl)
                };

                // Act.
                var config = new TrackingConfig(mockExecutionContext.Object, new[] { repository }, DefinitionId);

                // Assert.
                Assert.Equal(Path.Combine("322", "a"), config.ArtifactsDirectory);
                Assert.Equal("322", config.BuildDirectory);
                Assert.Equal(CollectionId, config.CollectionId);
                Assert.Equal(CollectionUrl, config.CollectionUrl);
                Assert.Equal(DefinitionId.ToString(), config.DefinitionId);
                Assert.Equal(DefinitionName, config.DefinitionName);
                Assert.Equal(3, config.FileFormatVersion);
                Assert.Equal(null, config.FileLocation);
                Assert.Equal("ea7c71421cca06c927f73627b66d6b4f4c3a5f4a", config.HashKey);
                Assert.Equal(RepositoryTypes.Git, config.RepositoryType);
                Assert.Equal(RepositoryUrl, config.RepositoryUrl);
                Assert.Equal(Path.Combine("322", "s"), config.SourcesDirectory);
                Assert.Equal("build", config.System);
                Assert.Equal(Path.Combine("322", "TestResults"), config.TestResultsDirectory);
                Assert.NotNull(config.RepositoryTrackingInfo);
                Assert.Equal(true, config.ShouldSerializeRepositoryTrackingInfo());
                Assert.Equal(1, config.RepositoryTrackingInfo.Count);
                Assert.Equal(RepositoryUrl, config.RepositoryTrackingInfo[0].RepositoryUrl);
            }
        }
Exemplo n.º 2
0
        public static MyCubeBlockDefinition ToMyCubeBlockDefinition(this DefinitionId definitionId)
        {
            var id = definitionId.ToString();

            return(MyDefinitionManager.Static
                   .GetDefinitionsOfType <MyCubeBlockDefinition>()
                   .First(
                       cbd => cbd.Id.TypeId.ToString() == definitionId.Id &&
                       cbd.Id.SubtypeId.String == definitionId.Type
                       ));
        }
        private TestHostContext Setup(out Mock <IExecutionContext> mockExecutionContext)
        {
            var tc = new TestHostContext(this);

            // Setup the execution context.
            mockExecutionContext = new Mock <IExecutionContext>();
            List <string> warnings;
            var           variables = new Variables(tc, new Dictionary <string, VariableValue>(), out warnings);

            variables.Set(Constants.Variables.System.CollectionId, CollectionId);
            variables.Set(WellKnownDistributedTaskVariables.TFCollectionUrl, CollectionUrl);
            variables.Set(Constants.Variables.System.DefinitionId, DefinitionId.ToString());
            variables.Set(Constants.Variables.Build.DefinitionName, DefinitionName);
            mockExecutionContext.Setup(x => x.Variables).Returns(variables);

            return(tc);
        }
        public void TrackingConfig_copy_legacy_ctor_should_fill_in_fields_correctly()
        {
            using (TestHostContext tc = Setup(out Mock <IExecutionContext> mockExecutionContext))
            {
                // Arrange.
                var legacyConfig = new LegacyTrackingConfig
                {
                    BuildDirectory = Path.Combine("path", "_work", "123"),
                    CollectionId   = CollectionId,
                    DefinitionId   = DefinitionId.ToString(),
                    HashKey        = "some_hash_key",
                    RepositoryUrl  = RepositoryUrl,
                    System         = "Build",
                };

                // Act.
                var config = new TrackingConfig(mockExecutionContext.Object, legacyConfig, "s", "git", true);

                // Assert.
                Assert.Equal(Path.Combine("123", "a"), config.ArtifactsDirectory);
                Assert.Equal("123", config.BuildDirectory);
                Assert.Equal(CollectionId, config.CollectionId);
                Assert.Equal(CollectionUrl, config.CollectionUrl);
                Assert.Equal(DefinitionId.ToString(), config.DefinitionId);
                Assert.Equal(null, config.DefinitionName);
                Assert.Equal(3, config.FileFormatVersion);
                Assert.Equal(null, config.FileLocation);
                Assert.Equal("some_hash_key", config.HashKey);
                Assert.Equal("git", config.RepositoryType);
                Assert.Equal(RepositoryUrl, config.RepositoryUrl);
                Assert.Equal(Path.Combine("123", "s"), config.SourcesDirectory);
                Assert.Equal("Build", config.System);
                Assert.Equal(Path.Combine("123", "TestResults"), config.TestResultsDirectory);
                Assert.NotNull(config.RepositoryTrackingInfo);
                Assert.Equal(false, config.ShouldSerializeRepositoryTrackingInfo());
            }
        }
Exemplo n.º 5
0
        protected override void ProcessRecord()
        {
            BaseParameters = new Dictionary <string, string>
            {
                { "SourceId", SourceId },
                { "ArtifactTypeId", ArtifactTypeId },
                { "ArtifactVersionId", ArtifactVersionId },
                { "MaxCreatedTime", MaxCreatedTime?.ToString() },
                { "MinCreatedTime", MinCreatedTime?.ToString() },
                { "DefinitionId", DefinitionId?.ToString() },
                { "QueryOrder", QueryOrder },
                { "$Expand", ExpandProperties != null?string.Join(",", ExpandProperties) : null }
            };

            var parameters = new ParallelRequestParams(
                "ArtifactVersionId",
                ArtifactVersionIds,
                BaseParameters
                );

            var requestTasks = ParallelRequestAsync(VssAuthenticator.AzureDevOpsHost, "DefaultCollection/One/_apis/release/releases", parameters);

            WriteObject(requestTasks.Result);
        }
Exemplo n.º 6
0
 public static MyDefinitionId ToMyDefinitionId(this DefinitionId definitionId)
 {
     return(MyDefinitionId.Parse(definitionId.ToString()));
 }