Ejemplo n.º 1
0
        public void CreatesTrackingConfig()
        {
            using (TestHostContext hc = Setup())
            {
                // Arrange.
                string         trackingFile = Path.Combine(_workFolder, "trackingconfig.json");
                DateTimeOffset testStartOn  = DateTimeOffset.Now;

                // Act.
                var newConfig = _trackingManager.Create(_ec.Object, new[] { _repository }, false);
                _trackingManager.UpdateTrackingConfig(_ec.Object, newConfig);

                // Assert.
                TrackingConfig config = _trackingManager.LoadExistingTrackingConfig(_ec.Object) as TrackingConfig;
                Assert.Equal(
                    Path.Combine("1", Constants.Build.Path.ArtifactsDirectory),
                    config.ArtifactsDirectory);
                Assert.Equal("1", config.BuildDirectory);
                Assert.Equal(CollectionId, config.CollectionId);
                Assert.Equal(CollectionUrl, config.CollectionUrl);
                Assert.Equal(DefinitionId, config.DefinitionId);
                Assert.Equal(DefinitionName, config.DefinitionName);
                Assert.Equal(3, config.FileFormatVersion);
                // Manipulate the expected seconds due to loss of granularity when the
                // date-time-offset is serialized in a friendly format.
                Assert.True(testStartOn.AddSeconds(-1) <= config.LastRunOn);
                Assert.True(DateTimeOffset.Now.AddSeconds(1) >= config.LastRunOn);
                Assert.Equal(RepositoryUrl, config.RepositoryUrl);
                Assert.Equal(
                    Path.Combine("1", Constants.Build.Path.SourcesDirectory),
                    config.SourcesDirectory);
                Assert.Equal("build", config.System);
                Assert.Equal(
                    Path.Combine("1", Constants.Build.Path.TestResultsDirectory),
                    config.TestResultsDirectory);
            }
        }