public void CreatesTrackingConfig() { using (TestHostContext hc = Setup()) { // Arrange. string trackingFile = Path.Combine(_workFolder, "trackingconfig.json"); DateTimeOffset testStartOn = DateTimeOffset.Now; // Act. _trackingManager.Create(_ec.Object, trackingFile); // Assert. TrackingConfig config = _trackingManager.LoadIfExists(_ec.Object, trackingFile); Assert.Equal("runner", config.PipelineDirectory); Assert.Equal($"runner{Path.DirectorySeparatorChar}runner", config.WorkspaceDirectory); Assert.Equal("actions/runner", config.RepositoryName); Assert.Equal(1, config.Repositories.Count); Assert.Equal($"runner{Path.DirectorySeparatorChar}runner", config.Repositories["actions/runner"].RepositoryPath); // 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); } }
public void CreatesTrackingConfig() { using (TestHostContext hc = Setup()) { // Arrange. const string HashKey = "Some hash key"; string trackingFile = Path.Combine(_workFolder, "trackingconfig.json"); DateTimeOffset testStartOn = DateTimeOffset.Now; // Act. _trackingManager.Create(_ec.Object, _repository, HashKey, trackingFile, false); // Assert. TrackingConfig config = _trackingManager.LoadIfExists(_ec.Object, trackingFile) 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); Assert.Equal(HashKey, config.HashKey); // 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); } }