public async Task CanUploadAndRetrieveAnAsset()
        {
            var releaseWithNoUpdate = new NewRelease("0.1")
            {
                Draft = true
            };
            var release = await _releaseClient.Create(_context.RepositoryOwner, _context.RepositoryName, releaseWithNoUpdate);

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

            var newAsset = new ReleaseAssetUpload("hello-world.txt", "text/plain", stream, null);

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

            Assert.True(result.Id > 0);

            var assets = await _releaseClient.GetAllAssets(_context.RepositoryOwner, _context.RepositoryName, release.Id);

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

            Assert.Equal(result.Id, asset.Id);
            Assert.NotNull(asset.Url);
            Assert.NotNull(asset.BrowserDownloadUrl);
        }
Exemplo n.º 2
0
        public async Task CanUploadAndRetrieveAnAsset()
        {
            var releaseWithNoUpdate = new ReleaseUpdate("0.1")
            {
                Draft = true
            };
            var release = await _releaseClient.Create(_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);
        }
        /// <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>
        public IObservable <Release> Create(string owner, string name, NewRelease data)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(data, "data");

            return(_client.Create(owner, name, data).ToObservable());
        }
Exemplo n.º 4
0
        public async Task SendsCreateToCorrectUrl()
        {
            var releaseWithNoUpdate = new NewRelease("0.1")
            {
                Draft = true
            };

            var release = await _releaseClient.Create(_context.RepositoryOwner, _context.RepositoryName, releaseWithNoUpdate);

            Assert.NotNull(release);
        }
Exemplo n.º 5
0
        public async Task ReturnsReleasesWithNullPublishDate()
        {
            // create a release without a publish date
            var releaseWithNoUpdate = new NewRelease("0.1")
            {
                Draft = true
            };
            await _releaseClient.Create(_context.RepositoryOwner, _context.RepositoryName, releaseWithNoUpdate);

            var releases = await _releaseClient.GetAll(_context.RepositoryOwner, _context.RepositoryName);

            Assert.True(releases.Count == 1);
            Assert.False(releases.First().PublishedAt.HasValue);
        }
Exemplo n.º 6
0
        public async Task CanDelete()
        {
            var releaseWithNoUpdate = new NewRelease("0.1")
            {
                Draft = true
            };
            var release = await _releaseClient.Create(_context.RepositoryOwner, _context.RepositoryName, releaseWithNoUpdate);

            var createdRelease = await _releaseClient.Get(_context.RepositoryOwner, _context.RepositoryName, release.Id);

            Assert.NotNull(createdRelease);

            await _releaseClient.Delete(_context.RepositoryOwner, _context.RepositoryName, createdRelease.Id);

            await Assert.ThrowsAsync <NotFoundException>(async() => await _releaseClient.Get(_context.RepositoryOwner, _context.RepositoryName, createdRelease.Id));
        }
Exemplo n.º 7
0
        public async Task CanChangeBodyOfRelease()
        {
            var releaseWithNoUpdate = new NewRelease("0.1")
            {
                Draft = true
            };
            var release = await _releaseClient.Create(_context.RepositoryOwner, _context.RepositoryName, releaseWithNoUpdate);

            var editRelease = release.ToUpdate();

            editRelease.Body  = "**This is an updated release";
            editRelease.Draft = false;

            var updatedRelease = await _releaseClient.Edit(_context.RepositoryOwner, _context.RepositoryName, release.Id, editRelease);

            Assert.Equal(release.Id, updatedRelease.Id);
            Assert.False(updatedRelease.Draft);
            Assert.Equal("**This is an updated release", updatedRelease.Body);
        }
Exemplo n.º 8
0
        public async Task CanDeleteAsset()
        {
            var releaseWithNoUpdate = new NewRelease("0.1")
            {
                Draft = true
            };
            var release = await _releaseClient.Create(_context.RepositoryOwner, _context.RepositoryName, releaseWithNoUpdate);

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

            var newAsset = new ReleaseAssetUpload("hello-world.txt", "text/plain", stream, null);

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

            var asset = await _releaseClient.GetAsset(_context.RepositoryOwner, _context.RepositoryName, result.Id);

            Assert.NotNull(asset);

            await _releaseClient.DeleteAsset(_context.RepositoryOwner, _context.RepositoryName, result.Id);

            await Assert.ThrowsAsync <NotFoundException>(async() => await _releaseClient.GetAsset(_context.RepositoryOwner, _context.RepositoryName, result.Id));
        }