public void ContributeAddsToBuilder() { // Uses git.properties file in test project var contrib = new GitInfoContributor(); var builder = new InfoBuilder(); contrib.Contribute(builder); var result = builder.Build(); Assert.NotNull(result); var gitDict = result["git"] as Dictionary<string, object>; Assert.NotNull(gitDict); Assert.Equal(7, gitDict.Count); Assert.True(gitDict.ContainsKey("build")); Assert.True(gitDict.ContainsKey("branch")); Assert.True(gitDict.ContainsKey("commit")); Assert.True(gitDict.ContainsKey("closest")); Assert.True(gitDict.ContainsKey("dirty")); Assert.True(gitDict.ContainsKey("remote")); Assert.True(gitDict.ContainsKey("tags")); // Verify times are correctly converted var gitDict2 = gitDict["build"] as Dictionary<string, object>; Assert.NotNull(gitDict2); Assert.True(gitDict2.ContainsKey("time")); var time = gitDict2["time"]; Assert.Equal(1499884839000, time); // Verify times are correctly converted var gitDict3 = gitDict["commit"] as Dictionary<string, object>; Assert.NotNull(gitDict3); Assert.True(gitDict3.ContainsKey("time")); time = gitDict3["time"]; Assert.Equal(1496926022000, time); }
public void ContributeWithNullBUilderThrows() { // Uses git.properties file in test project var contrib = new GitInfoContributor(); Assert.Throws <ArgumentNullException>(() => contrib.Contribute(null)); }
public void ContributeAddsToBuilder() { // Uses git.properties file in test project var contrib = new GitInfoContributor(); var builder = new InfoBuilder(); contrib.Contribute(builder); var result = builder.Build(); Assert.NotNull(result); var gitDict = result["git"] as Dictionary <string, object>; Assert.NotNull(gitDict); Assert.Equal(7, gitDict.Count); Assert.True(gitDict.ContainsKey("build")); Assert.True(gitDict.ContainsKey("branch")); Assert.True(gitDict.ContainsKey("commit")); Assert.True(gitDict.ContainsKey("closest")); Assert.True(gitDict.ContainsKey("dirty")); Assert.True(gitDict.ContainsKey("remote")); Assert.True(gitDict.ContainsKey("tags")); var gitBuildDict = gitDict["build"] as Dictionary <string, object>; Assert.NotNull(gitBuildDict); Assert.True(gitBuildDict.ContainsKey("time")); // Verify that datetime values are normalized correctly var gitBuildTime = gitBuildDict["time"]; Assert.Equal(DateTime.Parse("2017-07-12T18:40:39Z", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal), gitBuildTime); var gitCommitDict = gitDict["commit"] as Dictionary <string, object>; Assert.NotNull(gitCommitDict); Assert.True(gitCommitDict.ContainsKey("time")); // Verify that datetime values are normalized correctly var gitCommitTime = gitCommitDict["time"]; Assert.Equal(DateTime.Parse("2017-06-08T12:47:02Z", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal), gitCommitTime); }