public void Should_Return_Correct_Value() { // Given var info = new TeamCityInfoFixture().CreateBuildInfo(); // When var result = info.Number; // Then Assert.Equal(10, result); }
public void Should_Return_Empty_When_No_Properties() { // Given var info = new TeamCityInfoFixture().CreateBuildInfo(); // When var result = info.VcsBranchName; // Then Assert.Equal(string.Empty, result); }
public void Should_Return_Correct_Value() { // Given var info = new TeamCityInfoFixture().CreateBuildInfo(); // When var result = info.BuildConfName; // Then Assert.Equal("Cake Build", result); }
public void Should_Not_Be_Null() { // Given var info = new TeamCityInfoFixture().CreateEnvironmentInfo(); // When var result = info.PullRequest; // Then Assert.NotNull(result); }
public void Should_Return_Correct_Value() { // Given var info = new TeamCityInfoFixture().CreateBuildInfo(); // When var result = info.StartDateTime; // Then var expected = new DateTimeOffset?(new DateTime(2020, 08, 22, 12, 34, 56, DateTimeKind.Local)); Assert.Equal(expected, result); }
public void Should_Return_Correct_Value(string value, int?expected) { // Given var fixture = new TeamCityInfoFixture(); fixture.SetGitBranch(value); var info = fixture.CreatePullRequestInfo(); // When var result = info.Number; // Then Assert.Equal(expected, result); }
public void Should_Return_Correct_Value(string value, int?expected) { // Given var fixture = new TeamCityInfoFixture(); fixture.Environment.GetEnvironmentVariable("Git_Branch").Returns(value); var info = fixture.CreatePullRequestInfo(); // When var result = info.Number; // Then Assert.Equal(expected, result); }
public void Should_Return_Value_From_Properties() { // Given var fixture = new TeamCityInfoFixture(); fixture.SetBuildPropertiesContent(Properties.Resources.TeamCity_Build_Properties_Xml); fixture.SetConfigPropertiesContent(Properties.Resources.TeamCity_Config_Properties_Xml); var info = fixture.CreateBuildInfo(); // When var result = info.VcsBranchName; // Then Assert.Equal("refs/pull/5/merge", result); }
public void Should_Return_Null_If_Cannot_Parse_Values(string startDate, string startTime) { // Given var fixture = new TeamCityInfoFixture(); fixture.SetBuildStartDate(startDate); fixture.SetBuildStartTime(startTime); var info = fixture.CreateBuildInfo(); // When var result = info.StartDateTime; // Then Assert.Equal(null, result); }
public void Should_Return_Empty_When_Runner_Properties_File_Not_Created() { // Given var fixture = new TeamCityInfoFixture(); fixture.SetBuildPropertiesContent(Properties.Resources.TeamCity_Build_Properties_Xml); var info = fixture.CreateBuildInfo(); // When var buildProperties = info.BuildProperties; var runnerProperties = info.RunnerProperties; // Then Assert.NotEmpty(buildProperties); Assert.Empty(runnerProperties); }
public void Should_Return_Empty_ForAll_When_File_Not_Created() { // Given var fixture = new TeamCityInfoFixture(); var info = fixture.CreateBuildInfo(); // When var buildProperties = info.BuildProperties; var configProperties = info.ConfigProperties; var runnerProperties = info.RunnerProperties; // Then Assert.Empty(buildProperties); Assert.Empty(configProperties); Assert.Empty(runnerProperties); }
public void Should_Return_Correct_Value(string value, int?expected) { // Given var fixture = new TeamCityInfoFixture(); fixture.SetGitBranch(value); fixture.SetBuildPropertiesContent(Properties.Resources.TeamCity_Build_Properties_Xml); fixture.SetConfigPropertiesContent(Properties.Resources.TeamCity_Config_Properties_Xml); var info = fixture.CreatePullRequestInfo(); // When var result = info.Number; // Then Assert.Equal(expected, result); }
public void Should_Return_Runner_Values_When_Files_Exist() { // Given var fixture = new TeamCityInfoFixture(); fixture.SetBuildPropertiesContent(Properties.Resources.TeamCity_Build_Properties_Xml); fixture.SetRunnerPropertiesContent(Properties.Resources.TeamCity_Runner_Properties_Xml); var info = fixture.CreateBuildInfo(); // When var buildProperties = info.BuildProperties; var runnerProperties = info.RunnerProperties; // Then Assert.NotEmpty(buildProperties); Assert.NotEmpty(runnerProperties); Assert.Single(runnerProperties); Assert.Equal("run.cmd", runnerProperties["command.executable"]); }
public void Should_Return_Config_Values_When_Files_Exist() { // Given var fixture = new TeamCityInfoFixture(); fixture.SetBuildPropertiesContent(Properties.Resources.TeamCity_Build_Properties_Xml); fixture.SetConfigPropertiesContent(Properties.Resources.TeamCity_Config_Properties_Xml); var info = fixture.CreateBuildInfo(); // When var buildProperties = info.BuildProperties; var configProperties = info.ConfigProperties; // Then Assert.NotEmpty(buildProperties); Assert.NotEmpty(configProperties); Assert.Equal(5, configProperties.Count); Assert.Equal("3246", configProperties["build.number"]); }
public void Should_Use_Build_Server_Local_Time() { // Given var now = DateTime.Now; var startDate = now.ToString("yyyyMMdd", CultureInfo.InvariantCulture); var startTime = now.ToString("HHmmss", CultureInfo.InvariantCulture); var fixture = new TeamCityInfoFixture(); fixture.SetBuildStartDate(startDate); fixture.SetBuildStartTime(startTime); var info = fixture.CreateBuildInfo(); // When var result = info.StartDateTime; // Then var expected = new DateTimeOffset?(new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, DateTimeKind.Local)); Assert.Equal(expected, result); }