Example #1
0
        async public Task PatchGist()
        {
            var files = new Dictionary <string, string>
            {
                { "theAnswer", "42" },
                { "the Question", "I dunno" }
            };

            await Authorize(new[] { Scopes.Gist });

            var gist = await Api.Gists.New(files);

            var patch     = new Gist.EditGistPost(gist);
            var patchFile = patch.Files["theAnswer"];

            patchFile.Filename          = "theWrongAnswer";
            patchFile.Content           = "43";
            patch.Files["the Question"] = null;
            var patchedGist = await Api.Gists.Edit(patch);

            patchedGist.Files.Should().HaveCount(1);
            patchedGist.Files["theWrongAnswer"].Should().NotBeNull();
            patchedGist.Files["theWrongAnswer"].Content.Should().Be("43");
            patchedGist.Id.Should().Be(gist.Id);
        }
Example #2
0
        /// <summary>
        /// Edit a gist
        /// </summary>
        /// <param name="patch">The EditGistPost comprising the edits to be made</param>
        /// <returns>The edited Gist</returns>
        async public Task <Gist> Edit(Gist.EditGistPost patch)
        {
            var request  = CreateRequest("/gists/" + patch.Id);
            var response = await Patch <Gist.EditGistPost, Gist>(request, patch);

            return(response.Result);
        }
Example #3
0
        async public Task PatchGist()
        {
            var files = new Dictionary <string, string>
            {
                { "theAnswer", "42" },
                { "the Question", "I dunno" }
            };
            var api = GitHubApi.Create();
            await api.in2bitstest(new[] { Scopes.Gist });

            var gist = await api.Gists.New(files);

            Assert.AreEqual("42", gist.Files["theAnswer"].Content);
            var patch     = new Gist.EditGistPost(gist);
            var patchFile = patch.Files["theAnswer"];

            patchFile.Filename          = "theWrongAnswer";
            patchFile.Content           = "43";
            patch.Files["the Question"] = null;
            var patchedGist = await api.Gists.Edit(patch);

            Assert.AreEqual(1, patchedGist.Files.Count);
            var file = patchedGist.Files["theWrongAnswer"];

            Assert.IsNotNull(file);
            Assert.AreEqual("43", file.Content);
            Assert.AreEqual(gist.Id, patchedGist.Id);
        }