public void Should_Throw_If_Project_Name_Env_Var_Is_Empty() { // Given var credentials = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection"); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", string.Empty); // When var result = Record.Exception(() => new BaseAzureDevOpsProjectSettingsImpl(credentials)); // Then result.IsInvalidOperationException(); }
public void Should_Throw_If_Collection_Url_Env_Var_Is_Empty() { // Given var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", string.Empty); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject"); // When var result = Record.Exception(() => new AzureDevOpsBuildsSettings(creds)); // Then result.IsInvalidOperationException(); }
public void Should_Throw_If_Collection_Url_Env_Var_Is_WhiteSpace() { // Given var credentials = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", " "); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject"); // When var result = Record.Exception(() => new BaseAzureDevOpsProjectSettingsImpl(credentials)); // Then result.IsInvalidOperationException(); }
public void Should_Set_Credentials() { // Given var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection"); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject"); // When var settings = new AzureDevOpsBuildsSettings(creds); // Then settings.Credentials.ShouldBe(creds); }
public void Should_Throw_If_Pull_Request_Id_Is_Zero() { // Given var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("BUILD_REPOSITORY_URI", "http://example.com"); Environment.SetEnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTID", "0"); // When var result = Record.Exception(() => new AzureDevOpsPullRequestSettings(creds)); // Then result.IsInvalidOperationException(); }
public void Should_Set_Pull_Request_Id() { // Given var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("BUILD_REPOSITORY_URI", "http://example.com"); Environment.SetEnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTID", "42"); // When var settings = new AzureDevOpsPullRequestSettings(creds); // Then settings.PullRequestId.ShouldBe(42); }
public void Should_Set_Collection_Url() { // Given var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection"); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject"); Environment.SetEnvironmentVariable("BUILD_BUILDID", "42"); // When var settings = new AzureDevOpsBuildSettings(creds); // Then settings.CollectionUrl.ToString().ShouldBe(new Uri("https://example.com/collection").ToString()); }
public void Should_Throw_If_Repository_Url_Env_Var_Is_WhiteSpace() { // Given var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("BUILD_REPOSITORY_URI", " "); Environment.SetEnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTID", "42"); // When var result = Record.Exception(() => new AzureDevOpsPullRequestSettings(creds)); // Then result.IsInvalidOperationException(); }
public void Should_Throw_If_Build_Id_Is_Zero() { // Given var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection"); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject"); Environment.SetEnvironmentVariable("BUILD_BUILDID", "0"); // When var result = Record.Exception(() => new AzureDevOpsBuildSettings(creds)); // Then result.IsInvalidOperationException(); }
public void Should_Set_Project_Name() { // Given var projectName = "MyProject"; var credentials = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection"); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", projectName); // When var settings = new BaseAzureDevOpsProjectSettingsImpl(credentials); // Then settings.ProjectName.ShouldBe(projectName); }
public void Should_Throw_If_Project_Name_Env_Var_Is_WhiteSpace() { // Given var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection"); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", " "); Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo"); // When var result = Record.Exception(() => new AzureDevOpsBuildsSettings(creds)); // Then result.IsInvalidOperationException(); }
public void Should_Throw_If_Build_Id_Env_Var_Is_Set_But_Ctor_Build_Id_Value_Zero_With_OAuthToken() { // Given var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection"); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject"); Environment.SetEnvironmentVariable("BUILD_BUILDID", "20"); Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo"); // When var result = Record.Exception(() => AzureDevOpsBuildSettings.UsingAzurePipelinesOAuthToken(0)); // Then result.IsArgumentOutOfRangeException("buildId"); }
public void Should_Throw_If_Collection_Url_Env_Var_Is_WhiteSpace() { // Given var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", " "); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject"); Environment.SetEnvironmentVariable("BUILD_BUILDID", "42"); Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo"); // When var result = Record.Exception(() => new AzureDevOpsBuildSettings(creds)); // Then result.IsInvalidOperationException(); }
public void Should_Set_Build_Id_With_Ctor() { // Given var buildId = 42; var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection"); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject"); Environment.SetEnvironmentVariable("BUILD_BUILDID", "20"); Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo"); // When var settings = new AzureDevOpsBuildSettings(buildId, creds); // Then settings.BuildId.ShouldBe(buildId); }
public void Should_Set_Project_Name() { // Given var projectName = "MyProject"; var creds = new AzureDevOpsNtlmCredentials(); Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection"); Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", projectName); Environment.SetEnvironmentVariable("BUILD_BUILDID", "42"); Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo"); // When var settings = new AzureDevOpsBuildSettings(creds); // Then settings.ProjectName.ShouldBe(projectName); }