Beispiel #1
0
    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);
    }
        /// <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 IObservable <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(_client.Create(owner, name, newDeployKey).ToObservable());
        }