コード例 #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);
        }
コード例 #2
0
ファイル: GistTests.cs プロジェクト: noark9/IronGitHub
 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);
 }