Example #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);
    }
Example #2
0
 public FileElement(string name, string key, GistFileUpdate file)
     : base(name, String.Empty, UITableViewCellStyle.Subtitle)
 {
     File = file;
     Key  = key;
     if (file.Content != null)
     {
         Value = System.Text.Encoding.UTF8.GetByteCount(file.Content) + " bytes";
     }
 }
Example #3
0
        private void UpdateGist(List <Item> items)
        {
            var jsonContents   = JsonConvert.SerializeObject(items, Formatting.Indented);
            var gistFileUpdate = new GistFileUpdate();

            gistFileUpdate.Content     = jsonContents;
            gistFileUpdate.NewFileName = "todolist.json";
            var gistUpdate = new GistUpdate();

            gistUpdate.Description = "todolist";
            gistUpdate.Files.Add("todolist.json", gistFileUpdate);
            _githubClient.Gist
            .Edit(_gistId, gistUpdate)
            .GetAwaiter()
            .GetResult();
        }
        public void PostsToTheCorrectUrl()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new GistsClient(connection);

            var updateGist = new GistUpdate();

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

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

            client.Edit("1", updateGist);

            connection.Received().Patch <Gist>(Arg.Is <Uri>(u => u.ToString() == "gists/1"), Arg.Any <object>());
        }