Exemple #1
0
        public async Task CanUploadAndRetrieveAnAsset()
        {
            var releaseWithNoUpdate = new ReleaseUpdate("0.1")
            {
                Draft = true
            };
            var release = await _releaseClient.CreateRelease(_repositoryOwner, _repositoryName, releaseWithNoUpdate);

            var stream = Helper.LoadFixture("hello-world.txt");

            var newAsset = new ReleaseAssetUpload
            {
                ContentType = "text/plain", FileName = "hello-world.txt", RawData = stream
            };

            var result = await _releaseClient.UploadAsset(release, newAsset);

            Assert.True(result.Id > 0);

            var assets = await _releaseClient.GetAssets(_repositoryOwner, _repositoryName, release.Id);

            Assert.Equal(1, assets.Count);
            var asset = assets[0];

            Assert.Equal(result.Id, asset.Id);
            Assert.NotNull(asset.Url);
        }
Exemple #2
0
        /// <summary>
        /// Creates a new <see cref="Release"/> for the specified repository.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/repos/releases/#create-a-release">API documentation</a> for more information.
        /// </remarks>
        /// <param name="owner">The repository's owner</param>
        /// <param name="name">The repository's name</param>
        /// <param name="data">A description of the release to create</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>The created <see cref="Release"/>.</returns>
        public IObservable <Release> CreateRelease(string owner, string name, ReleaseUpdate data)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(data, "data");

            return(_client.CreateRelease(owner, name, data).ToObservable());
        }
Exemple #3
0
        public async Task ReturnsReleasesWithNullPublishDate()
        {
            // create a release without a publish date
            var releaseWithNoUpdate = new ReleaseUpdate("0.1")
            {
                Draft = true
            };
            var release = _releaseClient.CreateRelease(_repositoryOwner, _repositoryName, releaseWithNoUpdate).Result;

            var releases = await _releaseClient.GetAll(_repositoryOwner, _repositoryName);

            Assert.True(releases.Count == 1);
            Assert.False(releases.First().PublishedAt.HasValue);
        }
 public IObservable <Release> CreateRelease(string owner, string name, ReleaseUpdate data)
 {
     return(_client.CreateRelease(owner, name, data).ToObservable());
 }