public async Task ReturnsCorrectCountOfDeployKeysWithoutStart() { var deployKeys = await _fixture.GetAll(_context.RepositoryOwner, _context.RepositoryName); Assert.Equal(0, deployKeys.Count); var list = new List<NewDeployKey>(); var deployKeysCount = 5; for (int i = 0; i < deployKeysCount; i++) { var item = new NewDeployKey { Key = "ssh-rsa A" + i, // here we should genereate ssh-key some how Title = "KeyTitle" + i }; list.Add(item); } foreach (var key in list) { await _fixture.Create(_context.RepositoryOwner, _context.RepositoryName, key); } var options = new ApiOptions { PageSize = deployKeysCount, PageCount = 1 }; deployKeys = await _fixture.GetAll(_context.RepositoryOwner, _context.RepositoryName, options); Assert.Equal(deployKeysCount, deployKeys.Count); }
public async Task CanCreateADeployKey() { var deployKey = new NewDeployKey() { Key = _key, Title = _keyTitle }; var deployKeyResult = await _fixture.Create(_owner, _repository.Name, deployKey); Assert.NotNull(deployKeyResult); Assert.Equal(_key, deployKeyResult.Key); Assert.Equal(_keyTitle, deployKeyResult.Title); }
public async Task CanCreateADeployKeyWithRepositoryId() { var deployKey = new NewDeployKey { Key = _key, Title = _keyTitle }; var deployKeyResult = await _fixture.Create(_context.Repository.Id, deployKey); Assert.NotNull(deployKeyResult); Assert.Equal(_key, deployKeyResult.Key); Assert.Equal(_keyTitle, deployKeyResult.Title); }
/// <summary> /// Creates a new deploy key for a repository. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/keys/#create"> API documentation</a> for more information. /// </remarks> /// <param name="owner">The owner of the repository.</param> /// <param name="name">The name of the repository.</param> /// <param name="newDeployKey">The deploy key to create for the repository.</param> /// <returns></returns> public Task<DeployKey> Create(string owner, string name, NewDeployKey newDeployKey) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(newDeployKey, "newDeployKey"); if (string.IsNullOrWhiteSpace(newDeployKey.Title)) throw new ArgumentException("The new deploy key's title must not be null."); if (string.IsNullOrWhiteSpace(newDeployKey.Key)) throw new ArgumentException("The new deploy key's key must not be null."); return ApiConnection.Post<DeployKey>(ApiUrls.RepositoryDeployKeys(owner, name), newDeployKey); }
public async Task CanCreateADeployKey() { var deployKey = new NewDeployKey() { Key = _key, Title = _keyTitle }; var observable = _client.Create(_owner, _repository.Name, deployKey); var createdDeployKey = await observable; Assert.NotNull(createdDeployKey); Assert.Equal(_key, createdDeployKey.Key); Assert.Equal(_keyTitle, createdDeployKey.Title); }
public async Task CanRetrieveADeployKey() { var newDeployKey = new NewDeployKey() { Key = _key, Title = _keyTitle }; var deployKeyResult = await _fixture.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployKey); var deployKey = await _fixture.Get(_context.RepositoryOwner, _context.RepositoryName, deployKeyResult.Id); Assert.NotNull(deployKey); Assert.Equal(deployKeyResult.Id, deployKey.Id); Assert.Equal(_key, deployKey.Key); Assert.Equal(_keyTitle, deployKey.Title); }
/// <summary> /// Creates a new deploy key for a repository. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/keys/#create"> API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository.</param> /// <param name="newDeployKey">The deploy key to create for the repository.</param> public Task <DeployKey> Create(int repositoryId, NewDeployKey newDeployKey) { Ensure.ArgumentNotNull(newDeployKey, "newDeployKey"); if (string.IsNullOrWhiteSpace(newDeployKey.Title)) { throw new ArgumentException("The new deploy key's title must not be null."); } if (string.IsNullOrWhiteSpace(newDeployKey.Key)) { throw new ArgumentException("The new deploy key's key must not be null."); } return(ApiConnection.Post <DeployKey>(ApiUrls.RepositoryDeployKeys(repositoryId), newDeployKey)); }
public async Task CanRetrieveADeployKey() { var newDeployKey = new NewDeployKey() { Key = _key, Title = _keyTitle }; var createdDeployKey = await _client.Create(_owner, _repository.Name, newDeployKey); var deployKey = await _client.Get(_owner, _repository.Name, createdDeployKey.Id); Assert.NotNull(deployKey); Assert.Equal(createdDeployKey.Id, deployKey.Id); Assert.Equal(_key, deployKey.Key); Assert.Equal(_keyTitle, deployKey.Title); }
public async Task CanRetrieveAllDeployKeys() { var deployKeys = await _client.GetAll(_owner, _repository.Name).ToList(); Assert.Empty(deployKeys); var deployKey = new NewDeployKey() { Key = _key, Title = _keyTitle }; await _client.Create(_owner, _repository.Name, deployKey); deployKeys = await _client.GetAll(_owner, _repository.Name).ToList(); Assert.Equal(1, deployKeys.Count); Assert.Equal(_key, deployKeys[0].Key); Assert.Equal(_keyTitle, deployKeys[0].Title); }
/// <summary> /// Creates a new deploy key for a repository. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/keys/#create"> API documentation</a> for more information. /// </remarks> /// <param name="owner">The owner of the repository.</param> /// <param name="name">The name of the repository.</param> /// <param name="newDeployKey">The deploy key to create for the repository.</param> public Task <DeployKey> Create(string owner, string name, NewDeployKey newDeployKey) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(newDeployKey, "newDeployKey"); if (string.IsNullOrWhiteSpace(newDeployKey.Title)) { throw new ArgumentException("The new deploy key's title must not be null."); } if (string.IsNullOrWhiteSpace(newDeployKey.Key)) { throw new ArgumentException("The new deploy key's key must not be null."); } return(ApiConnection.Post <DeployKey>(ApiUrls.RepositoryDeployKeys(owner, name), newDeployKey)); }
public async Task CanRetrieveAllDeployKeysWithRepositoryId() { var deployKeys = await _fixture.GetAll(_context.RepositoryOwner, _context.RepositoryName); Assert.Equal(0, deployKeys.Count); var deployKey = new NewDeployKey { Key = _key, Title = _keyTitle }; await _fixture.Create(_context.Repository.Id, deployKey); deployKeys = await _fixture.GetAll(_context.Repository.Id); Assert.Equal(1, deployKeys.Count); Assert.Equal(_key, deployKeys[0].Key); Assert.Equal(_keyTitle, deployKeys[0].Title); }
public async Task CanRemoveADeployKey() { var newDeployKey = new NewDeployKey() { Key = _key, Title = _keyTitle }; await _fixture.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployKey); var deployKeys = await _fixture.GetAll(_context.RepositoryOwner, _context.RepositoryName); Assert.Equal(1, deployKeys.Count); Assert.Equal(_key, deployKeys[0].Key); Assert.Equal(_keyTitle, deployKeys[0].Title); await _fixture.Delete(_context.RepositoryOwner, _context.RepositoryName, deployKeys[0].Id); deployKeys = await _fixture.GetAll(_context.RepositoryOwner, _context.RepositoryName); Assert.Equal(0, deployKeys.Count); }
/// <summary> /// Creates a new deploy key for a repository. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/keys/#create"> API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository.</param> /// <param name="newDeployKey">The deploy key to create for the repository.</param> public Task<DeployKey> Create(long repositoryId, NewDeployKey newDeployKey) { Ensure.ArgumentNotNull(newDeployKey, "newDeployKey"); if (string.IsNullOrWhiteSpace(newDeployKey.Title)) throw new ArgumentException("The new deploy key's title must not be null."); if (string.IsNullOrWhiteSpace(newDeployKey.Key)) throw new ArgumentException("The new deploy key's key must not be null."); return ApiConnection.Post<DeployKey>(ApiUrls.RepositoryDeployKeys(repositoryId), newDeployKey); }
public async Task ReturnsDistinctResultsBasedOnStartPageWithRepositoryId() { var list = new List<NewDeployKey>(); var deployKeysCount = 5; for (int i = 0; i < deployKeysCount; i++) { var item = new NewDeployKey { Key = "ssh-rsa A" + i, // here we should genereate ssh-key some how Title = "KeyTitle" + i }; list.Add(item); } foreach (var key in list) { await _fixture.Create(_context.Repository.Id, key); } var startOptions = new ApiOptions { PageSize = 2, PageCount = 1 }; var firstPage = await _fixture.GetAll(_context.Repository.Id, startOptions); var skipStartOptions = new ApiOptions { PageSize = 2, PageCount = 1, StartPage = 2 }; var secondPage = await _fixture.GetAll(_context.Repository.Id, skipStartOptions); Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); }