Beispiel #1
0
    public async Task CanCreateEditAndDeleteAGist()
    {
        var newGist = new NewGist {
            Description = "my new gist", Public = true
        };

        newGist.Files.Add("myGistTestFile.cs", "new GistsClient(connection).Create();");

        var createdGist = await _fixture.Create(newGist);

        Assert.NotNull(createdGist);
        Assert.Equal(newGist.Description, createdGist.Description);
        Assert.Equal(newGist.Public, createdGist.Public);

        var gistUpdate = new GistUpdate {
            Description = "my newly updated gist"
        };
        var gistFileUpdate = new GistFileUpdate
        {
            NewFileName = "myNewGistTestFile.cs",
            Content     = "new GistsClient(connection).Edit();"
        };

        gistUpdate.Files.Add("myGistTestFile.cs", gistFileUpdate);

        var updatedGist = await _fixture.Edit(createdGist.Id, gistUpdate);

        Assert.NotNull(updatedGist);
        Assert.Equal(updatedGist.Description, gistUpdate.Description);

        await _fixture.Delete(createdGist.Id);
    }
        public async Task CreateGistAsync(string gistName, string firstFileContent, bool isPublic)
        {
            var newGist = new NewGist
            {
                Public      = isPublic,
                Description = "Gist created from visual studio extension",
            };

            newGist.Files.Add(gistName, firstFileContent);
            await gistClient.Create(newGist);
        }
        /// <summary>
        /// Creates a new gist
        /// </summary>
        /// <remarks>
        /// http://developer.github.com/v3/gists/#create-a-gist
        /// </remarks>
        /// <param name="newGist">The new gist to create</param>
        public IObservable <Gist> Create(NewGist newGist)
        {
            Ensure.ArgumentNotNull(newGist, nameof(newGist));

            return(_client.Create(newGist).ToObservable());
        }