示例#1
0
        public void MarksTrackingConfigForGarbageCollection_Legacy()
        {
            using (TestHostContext hc = Setup())
            {
                // Arrange.
                // It doesn't matter for this test whether the line endings are CRLF or just LF.
                const string TrackingContents = @"{
    ""system"" : ""build"", 
    ""collectionId"" = ""7aee6dde-6381-4098-93e7-50a8264cf066"", 
    ""definitionId"" = ""7"", 
    ""repositoryUrl"" = ""http://*****:*****@"{
  ""build_artifactstagingdirectory"": ""b00335b6\\artifacts"",
  ""agent_builddirectory"": ""b00335b6"",
  ""collectionUrl"": ""http://contoso:8080/tfs/DefaultCollection/"",
  ""definitionName"": null,
  ""fileFormatVersion"": 3,
  ""lastRunOn"": """",
  ""repositoryType"": """",
  ""lastMaintenanceAttemptedOn"": """",
  ""lastMaintenanceCompletedOn"": """",
  ""build_sourcesdirectory"": ""b00335b6\\s"",
  ""common_testresultsdirectory"": ""b00335b6\\TestResults"",
  ""collectionId"": ""7aee6dde-6381-4098-93e7-50a8264cf066"",
  ""definitionId"": ""7"",
  ""hashKey"": ""b00335b6923adfa64f46f3abb7da1cdc0d9bae6c"",
  ""repositoryUrl"": ""http://contoso:8080/tfs/DefaultCollection/_git/gitTest"",
  ""system"": ""build""
}";
                Assert.Equal(ExpectedGCContents, gcContents);
            }
        }
        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());
            }
        }